ESM: Added remaining Base64 ops and created a Base64 library. Added the prefer-const eslint rule.

This commit is contained in:
n1474335 2018-04-02 17:10:51 +01:00
parent 9b4fc3d3aa
commit 041cd9fb8e
30 changed files with 986 additions and 825 deletions

View file

@ -1,4 +1,5 @@
import Utils from "../Utils.js";
import {toBase64} from "../lib/Base64";
import CryptoJS from "crypto-js";
import forge from "imports-loader?jQuery=>null!node-forge/dist/forge.min.js";
import {blowfish as Blowfish} from "sladex-blowfish";
@ -366,7 +367,7 @@ DES uses a key length of 8 bytes (64 bits).`;
input = Utils.convertToByteString(input, inputType);
Blowfish.setIV(Utils.toBase64(iv), 0);
Blowfish.setIV(toBase64(iv), 0);
const enc = Blowfish.encrypt(input, key, {
outputType: Cipher._BLOWFISH_OUTPUT_TYPE_LOOKUP[outputType],
@ -395,7 +396,7 @@ DES uses a key length of 8 bytes (64 bits).`;
input = inputType === "Raw" ? Utils.strToByteArray(input) : input;
Blowfish.setIV(Utils.toBase64(iv), 0);
Blowfish.setIV(toBase64(iv), 0);
const result = Blowfish.decrypt(input, key, {
outputType: Cipher._BLOWFISH_OUTPUT_TYPE_LOOKUP[inputType], // This actually means inputType. The library is weird.

View file

@ -2,6 +2,7 @@ import * as ExifParser from "exif-parser";
import removeEXIF from "../vendor/remove-exif.js";
import Utils from "../Utils.js";
import FileType from "./FileType.js";
import {fromBase64, toBase64} from "../lib/Base64";
/**
@ -96,7 +97,7 @@ const Image = {
case "Base64":
// Don't trust the Base64 entered by the user.
// Unwrap it first, then re-encode later.
input = Utils.fromBase64(input, null, "byteArray");
input = fromBase64(input, null, "byteArray");
break;
case "Raw":
default:
@ -113,7 +114,7 @@ const Image = {
}
// Add image data to URI
dataURI += "base64," + Utils.toBase64(input);
dataURI += "base64," + toBase64(input);
return "<img src='" + dataURI + "'>";
},

View file

@ -1,4 +1,5 @@
import Utils from "../Utils.js";
import {fromBase64} from "../lib/Base64";
import * as r from "jsrsasign";
@ -43,7 +44,7 @@ const PublicKey = {
cert.readCertPEM(input);
break;
case "Base64":
cert.readCertHex(Utils.toHex(Utils.fromBase64(input, null, "byteArray"), ""));
cert.readCertHex(Utils.toHex(fromBase64(input, null, "byteArray"), ""));
break;
case "Raw":
cert.readCertHex(Utils.toHex(Utils.strToByteArray(input), ""));