mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
Improved performance of str/array buffer conversions
This commit is contained in:
parent
7a2517fd61
commit
659325c85a
8 changed files with 30 additions and 23 deletions
|
@ -25,12 +25,12 @@ import OperationError from "../errors/OperationError.mjs";
|
|||
*/
|
||||
export function toBase64(data, alphabet="A-Za-z0-9+/=") {
|
||||
if (!data) return "";
|
||||
if (typeof data == "string") {
|
||||
data = Utils.strToArrayBuffer(data);
|
||||
}
|
||||
if (data instanceof ArrayBuffer) {
|
||||
data = new Uint8Array(data);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
data = Utils.strToByteArray(data);
|
||||
}
|
||||
|
||||
alphabet = Utils.expandAlphRange(alphabet).join("");
|
||||
if (alphabet.length !== 64 && alphabet.length !== 65) { // Allow for padding
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue