/* * Copyright 2015, Mozilla Foundation and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
#include"ClearKeyBase64.h"
#include <algorithm>
using std::string; using std::vector;
/** * Take a base64-encoded string, convert (in-place) each character to its * corresponding value in the [0x00, 0x3f] range, and truncate any padding.
*/ staticbool Decode6Bit(string& aStr) { for (size_t i = 0; i < aStr.length(); i++) { if (aStr[i] >= 'A' && aStr[i] <= 'Z') {
aStr[i] -= 'A';
} elseif (aStr[i] >= 'a' && aStr[i] <= 'z') {
aStr[i] -= 'a' - 26;
} elseif (aStr[i] >= '0' && aStr[i] <= '9') {
aStr[i] -= '0' - 52;
} elseif (aStr[i] == '-' || aStr[i] == '+') {
aStr[i] = 62;
} elseif (aStr[i] == '_' || aStr[i] == '/') {
aStr[i] = 63;
} else { // Truncate '=' padding at the end of the aString. if (aStr[i] != '=') {
aStr.erase(i, string::npos); returnfalse;
}
aStr[i] = '\0';
aStr.resize(i); break;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.