diff --git a/package-lock.json b/package-lock.json index c2710b1..2d61b84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1110,15 +1110,6 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "@types/resolve": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", - "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -1570,12 +1561,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", - "dev": true - }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -2415,12 +2400,6 @@ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, - "estree-walker": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", - "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", - "dev": true - }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -3935,12 +3914,6 @@ "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", "dev": true }, - "is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", - "dev": true - }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -6306,28 +6279,6 @@ "acorn": "^7.1.0" } }, - "rollup-plugin-node-resolve": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz", - "integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==", - "dev": true, - "requires": { - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1", - "rollup-pluginutils": "^2.8.1" - } - }, - "rollup-pluginutils": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", - "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", - "dev": true, - "requires": { - "estree-walker": "^0.6.1" - } - }, "rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/src/cipher-core.js b/src/cipher-core.js index 85e910a..6b74f0e 100644 --- a/src/cipher-core.js +++ b/src/cipher-core.js @@ -30,7 +30,7 @@ export class Cipher extends BufferedBlockAlgorithm { * * @example * - * const cipher = CryptoJS.algo.AES.create( + * const cipher = new Cipher( * CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray } * ); */ @@ -70,7 +70,7 @@ export class Cipher extends BufferedBlockAlgorithm { * const cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); */ static createEncryptor(key, cfg) { - return this.create(this._ENC_XFORM_MODE, key, cfg); + return new this(this._ENC_XFORM_MODE, key, cfg); } /** @@ -88,7 +88,7 @@ export class Cipher extends BufferedBlockAlgorithm { * const cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); */ static createDecryptor(key, cfg) { - return this.create(this._DEC_XFORM_MODE, key, cfg); + return new this(this._DEC_XFORM_MODE, key, cfg); } /** @@ -221,7 +221,7 @@ export class BlockCipherMode extends Base { * * @example * - * const mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + * const mode = new BlockCipherMode(cipher, iv.words); */ constructor(cipher, iv) { super(); @@ -243,7 +243,7 @@ export class BlockCipherMode extends Base { * const mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); */ static createEncryptor(cipher, iv) { - return this.Encryptor.create(cipher, iv); + return new this.Encryptor(cipher, iv); } /** @@ -259,7 +259,7 @@ export class BlockCipherMode extends Base { * const mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); */ static createDecryptor(cipher, iv) { - return this.Decryptor.create(cipher, iv); + return new this.Decryptor(cipher, iv); } } @@ -390,7 +390,7 @@ export const Pkcs7 = { for (let i = 0; i < nPaddingBytes; i += 4) { paddingWords.push(paddingWord); } - const padding = WordArray.create(paddingWords, nPaddingBytes); + const padding =new WordArray(paddingWords, nPaddingBytes); // Add padding data.concat(padding); @@ -524,7 +524,7 @@ export class CipherParams extends Base { * * @example * - * var cipherParams = CryptoJS.lib.CipherParams.create({ + * let cipherParams =new CipherParams({ * ciphertext: ciphertextWordArray, * key: keyWordArray, * iv: ivWordArray, @@ -553,9 +553,9 @@ export class CipherParams extends Base { * * @example * - * var string = cipherParams + ''; - * var string = cipherParams.toString(); - * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + * let string = cipherParams + ''; + * let string = cipherParams.toString(); + * let string = cipherParams.toString(CryptoJS.format.OpenSSL); */ toString(formatter) { return (formatter || this.formatter).stringify(this); @@ -577,7 +577,7 @@ export const OpenSSLFormatter = { * * @example * - * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + * let openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); */ stringify(cipherParams) { let wordArray; @@ -590,7 +590,7 @@ export const OpenSSLFormatter = { // Format if (salt) { - wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + wordArray =new WordArray([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); } else { wordArray = ciphertext; } @@ -609,7 +609,7 @@ export const OpenSSLFormatter = { * * @example * - * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + * let cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); */ parse(openSSLStr) { let salt; @@ -623,14 +623,14 @@ export const OpenSSLFormatter = { // Test for salt if (ciphertextWords[0] === 0x53616c74 && ciphertextWords[1] === 0x65645f5f) { // Extract salt - salt = WordArray.create(ciphertextWords.slice(2, 4)); + salt =new WordArray(ciphertextWords.slice(2, 4)); // Remove salt from ciphertext ciphertextWords.splice(0, 4); ciphertext.sigBytes -= 16; } - return CipherParams.create({ + return new CipherParams({ ciphertext, salt }); @@ -655,11 +655,11 @@ export class SerializableCipher extends Base { * * @example * - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * .encrypt(CryptoJS.algo.AES, message, key); - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * .encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * .encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); */ static encrypt(cipher, message, key, cfg) { @@ -674,7 +674,7 @@ export class SerializableCipher extends Base { const cipherCfg = encryptor.cfg; // Create and return serializable cipher params - return CipherParams.create({ + return new CipherParams({ ciphertext, key, iv: cipherCfg.iv, @@ -700,10 +700,10 @@ export class SerializableCipher extends Base { * * @example * - * var plaintext = CryptoJS.lib.SerializableCipher + * let plaintext = CryptoJS.lib.SerializableCipher * .decrypt(CryptoJS.algo.AES, formattedCiphertext, key, * { iv: iv, format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.SerializableCipher + * let plaintext = CryptoJS.lib.SerializableCipher * .decrypt(CryptoJS.algo.AES, ciphertextParams, key, * { iv: iv, format: CryptoJS.format.OpenSSL }); */ @@ -735,7 +735,7 @@ export class SerializableCipher extends Base { * * @example * - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * ._parse(ciphertextStringOrParams, format); */ static _parse(ciphertext, format) { @@ -778,8 +778,8 @@ export const OpenSSLKdf = { * * @example * - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + * let derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * let derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); */ execute(password, keySize, ivSize, salt) { let _salt = salt; @@ -790,16 +790,16 @@ export const OpenSSLKdf = { } // Derive key and IV - const key = EvpKDFAlgo.create({ + const key =new EvpKDFAlgo({ keySize: keySize + ivSize }).compute(password, _salt); // Separate key and IV - const iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + const iv =new WordArray(key.words.slice(keySize), ivSize * 4); key.sigBytes = keySize * 4; // Return params - return CipherParams.create({ + return new CipherParams({ key, iv, salt: _salt @@ -826,9 +826,9 @@ export class PasswordBasedCipher extends SerializableCipher { * * @example * - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher + * let ciphertextParams = CryptoJS.lib.PasswordBasedCipher * .encrypt(CryptoJS.algo.AES, message, 'password'); - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher + * let ciphertextParams = CryptoJS.lib.PasswordBasedCipher * .encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); */ static encrypt(cipher, message, password, cfg) { @@ -865,10 +865,10 @@ export class PasswordBasedCipher extends SerializableCipher { * * @example * - * var plaintext = CryptoJS.lib.PasswordBasedCipher + * let plaintext = CryptoJS.lib.PasswordBasedCipher * .decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', * { format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.PasswordBasedCipher + * let plaintext = CryptoJS.lib.PasswordBasedCipher * .decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', * { format: CryptoJS.format.OpenSSL }); */ diff --git a/src/core.js b/src/core.js index f7c98e9..aa35d00 100644 --- a/src/core.js +++ b/src/core.js @@ -4,21 +4,6 @@ * Base class for inheritance. */ export class Base { - /** - * Extends this object and runs the init method. - * Arguments to create() will be passed to init(). - * - * @return {Object} The new object. - * - * @static - * - * @example - * - * var instance = MyType.create(); - */ - static create(...args) { - return new this(...args); - } /** * Copies properties into this object. @@ -42,7 +27,7 @@ export class Base { * * @example * - * var clone = instance.clone(); + * let clone = instance.clone(); */ clone() { const clone = new this.constructor(); @@ -66,9 +51,9 @@ export class WordArray extends Base { * * @example * - * var wordArray = CryptoJS.lib.WordArray.create(); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + * let wordArray = new WordArray(); + * let wordArray = new WordArray([0x00010203, 0x04050607]); + * let wordArray = new WordArray([0x00010203, 0x04050607], 6); */ constructor(words = [], sigBytes = words.length * 4) { super(); @@ -125,7 +110,7 @@ export class WordArray extends Base { * * @example * - * var wordArray = CryptoJS.lib.WordArray.random(16); + * let wordArray = CryptoJS.lib.WordArray.random(16); */ static random(nBytes) { const words = []; @@ -164,9 +149,9 @@ export class WordArray extends Base { * * @example * - * var string = wordArray + ''; - * var string = wordArray.toString(); - * var string = wordArray.toString(CryptoJS.enc.Utf8); + * let string = wordArray + ''; + * let string = wordArray.toString(); + * let string = wordArray.toString(CryptoJS.enc.Utf8); */ toString(encoder = Hex) { return encoder.stringify(this); @@ -238,7 +223,7 @@ export class WordArray extends Base { * * @example * - * var clone = wordArray.clone(); + * let clone = wordArray.clone(); */ clone() { const clone = super.clone.call(this); @@ -263,7 +248,7 @@ export const Hex = { * * @example * - * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + * let hexString = CryptoJS.enc.Hex.stringify(wordArray); */ stringify(wordArray) { // Shortcuts @@ -294,7 +279,7 @@ export const Hex = { * * @example * - * var wordArray = CryptoJS.enc.Hex.parse(hexString); + * let wordArray = CryptoJS.enc.Hex.parse(hexString); */ parse(hexStr) { // Shortcut @@ -325,7 +310,7 @@ export const Latin1 = { * * @example * - * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + * let latin1String = CryptoJS.enc.Latin1.stringify(wordArray); */ stringify(wordArray) { // Shortcuts @@ -355,7 +340,7 @@ export const Latin1 = { * * @example * - * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); + * let wordArray = CryptoJS.enc.Latin1.parse(latin1String); */ parse(latin1Str) { // Shortcut @@ -386,7 +371,7 @@ export const Utf8 = { * * @example * - * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + * let utf8String = CryptoJS.enc.Utf8.stringify(wordArray); */ stringify(wordArray) { try { @@ -407,7 +392,7 @@ export const Utf8 = { * * @example * - * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); + * let wordArray = CryptoJS.enc.Utf8.parse(utf8String); */ parse(utf8Str) { return Latin1.parse(unescape(encodeURIComponent(utf8Str))); @@ -478,8 +463,8 @@ export class BufferedBlockAlgorithm extends Base { * * @example * - * var processedData = bufferedBlockAlgorithm._process(); - * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + * let processedData = bufferedBlockAlgorithm._process(); + * let processedData = bufferedBlockAlgorithm._process(!!'flush'); */ _process(doFlush) { let processedWords; @@ -533,7 +518,7 @@ export class BufferedBlockAlgorithm extends Base { * * @example * - * var clone = bufferedBlockAlgorithm.clone(); + * let clone = bufferedBlockAlgorithm.clone(); */ clone() { const clone = super.clone.call(this); @@ -576,7 +561,7 @@ export class Hasher extends BufferedBlockAlgorithm { * * @example * - * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + * let SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); */ static _createHelper(SubHasher) { return (message, cfg) => new SubHasher(cfg).finalize(message); @@ -593,7 +578,7 @@ export class Hasher extends BufferedBlockAlgorithm { * * @example * - * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + * let HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); */ static _createHmacHelper(SubHasher) { return (message, key) => new HMAC(SubHasher, key).finalize(message); @@ -647,9 +632,9 @@ export class Hasher extends BufferedBlockAlgorithm { * * @example * - * var hash = hasher.finalize(); - * var hash = hasher.finalize('message'); - * var hash = hasher.finalize(wordArray); + * let hash = hasher.finalize(); + * let hash = hasher.finalize('message'); + * let hash = hasher.finalize(wordArray); */ finalize(messageUpdate) { // Final message update @@ -676,7 +661,7 @@ export class HMAC extends Base { * * @example * - * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + * let hmacHasher =new HMAC(CryptoJS.algo.SHA256, key); */ constructor(SubHasher, key) { super(); @@ -769,9 +754,9 @@ export class HMAC extends Base { * * @example * - * var hmac = hmacHasher.finalize(); - * var hmac = hmacHasher.finalize('message'); - * var hmac = hmacHasher.finalize(wordArray); + * let hmac = hmacHasher.finalize(); + * let hmac = hmacHasher.finalize('message'); + * let hmac = hmacHasher.finalize(wordArray); */ finalize(messageUpdate) { // Shortcut diff --git a/src/enc-base64.js b/src/enc-base64.js index 822b7a2..da41ad3 100644 --- a/src/enc-base64.js +++ b/src/enc-base64.js @@ -14,7 +14,7 @@ const parseLoop = (base64Str, base64StrLength, reverseMap) => { nBytes += 1; } } - return WordArray.create(words, nBytes); + return new WordArray(words, nBytes); }; /** diff --git a/src/evpkdf.js b/src/evpkdf.js index 5f974b2..72304fe 100644 --- a/src/evpkdf.js +++ b/src/evpkdf.js @@ -16,9 +16,9 @@ export class EvpKDFAlgo extends Base { * * @example * - * const kdf = CryptoJS.algo.EvpKDF.create(); - * const kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); - * const kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + * const kdf = new EvpKDF(); + * const kdf = new EvpKDF({ keySize: 8 }); + * const kdf = new EvpKDF({ keySize: 8, iterations: 1000 }); */ constructor(cfg) { super(); @@ -60,10 +60,10 @@ export class EvpKDFAlgo extends Base { const { cfg } = this; // Init hasher - const hasher = cfg.hasher.create(); + const hasher =new cfg.hasher(); // Initial values - const derivedKey = WordArray.create(); + const derivedKey =new WordArray(); // Shortcuts const derivedKeyWords = derivedKey.words; @@ -104,8 +104,8 @@ export class EvpKDFAlgo extends Base { * * @example * - * var key = CryptoJS.EvpKDF(password, salt); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + * let key = CryptoJS.EvpKDF(password, salt); + * let key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * let key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); */ -export const EvpKDF = (password, salt, cfg) => EvpKDFAlgo.create(cfg).compute(password, salt); +export const EvpKDF = (password, salt, cfg) => new EvpKDFAlgo(cfg).compute(password, salt); diff --git a/src/md5.js b/src/md5.js index 3e7083f..ba013a1 100644 --- a/src/md5.js +++ b/src/md5.js @@ -225,8 +225,8 @@ export class MD5Algo extends Hasher { * * @example * - * var hash = CryptoJS.MD5('message'); - * var hash = CryptoJS.MD5(wordArray); + * let hash = CryptoJS.MD5('message'); + * let hash = CryptoJS.MD5(wordArray); */ export const MD5 = Hasher._createHelper(MD5Algo); @@ -242,6 +242,6 @@ export const MD5 = Hasher._createHelper(MD5Algo); * * @example * - * var hmac = CryptoJS.HmacMD5(message, key); + * let hmac = CryptoJS.HmacMD5(message, key); */ export const HmacMD5 = Hasher._createHmacHelper(MD5Algo); diff --git a/src/x64-core.js b/src/x64-core.js index 1592ba2..8fbcf22 100644 --- a/src/x64-core.js +++ b/src/x64-core.js @@ -17,7 +17,7 @@ export class X64Word extends Base { * * @example * - * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + * let x64Word = new X64Word(0x00010203, 0x04050607); */ constructor(high, low) { super(); @@ -42,16 +42,16 @@ export class X64WordArray extends Base { * * @example * - * var wordArray = CryptoJS.x64.WordArray.create(); + * let wordArray =new X64WordArray(); * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * let wordArray =new X64WordArray([ + * new x64Word(0x00010203, 0x04050607), + * new x64Word(0x18191a1b, 0x1c1d1e1f) * ]); * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * let wordArray =new X64WordArray([ + * new x64Word(0x00010203, 0x04050607), + * new x64Word(0x18191a1b, 0x1c1d1e1f) * ], 10); */ constructor(words = [], sigBytes = words.length * 8) { @@ -68,7 +68,7 @@ export class X64WordArray extends Base { * * @example * - * var x32WordArray = x64WordArray.toX32(); + * let x32WordArray = x64WordArray.toX32(); */ toX32() { // Shortcuts @@ -83,7 +83,7 @@ export class X64WordArray extends Base { x32Words.push(x64Word.low); } - return X32WordArray.create(x32Words, this.sigBytes); + return new X32WordArray(x32Words, this.sigBytes); } /** @@ -93,7 +93,7 @@ export class X64WordArray extends Base { * * @example * - * var clone = x64WordArray.clone(); + * let clone = x64WordArray.clone(); */ clone() { const clone = super.clone.call(this); diff --git a/test/md5.profile.test.js b/test/md5.profile.test.js index 02345fa..a198fbf 100644 --- a/test/md5.profile.test.js +++ b/test/md5.profile.test.js @@ -12,12 +12,12 @@ describe('algo-md5-profile', () => { singlePartMessage += '12345678901234567890123456789012345678901234567890'; i++; } - expect(C.algo.MD5.create().finalize(singlePartMessage)).toMatchObject(WORD_ARRAY_TEST); + expect(new C.algo.MD5().finalize(singlePartMessage)).toMatchObject(WORD_ARRAY_TEST); }); test('profileMultiPartMessage', () => { let i = 0; - const md5 = C.algo.MD5.create(); + const md5 =new C.algo.MD5(); while (i < 500) { md5.update('12345678901234567890123456789012345678901234567890'); i++; diff --git a/test/md5.test.js b/test/md5.test.js index dbe1371..fbb219b 100644 --- a/test/md5.test.js +++ b/test/md5.test.js @@ -1,4 +1,4 @@ -import C from '../lib/index.js'; +import C from '../src/index.js'; const VECTOR_TEST_CONFIG = [ [1, '', 'd41d8cd98f00b204e9800998ecf8427e'], @@ -27,7 +27,7 @@ describe('algo-md5-test', () => { ); describe('testClone', () => { - const md5 = C.algo.MD5.create(); + const md5 =new C.algo.MD5(); test.each(CLONE_TEST_CONFIG)( 'return %s, %s', (a, expected) => { @@ -38,7 +38,7 @@ describe('algo-md5-test', () => { test('testUpdateAndLongMessage', () => { let i = 0; - const md5 = C.algo.MD5.create(); + const md5 =new C.algo.MD5(); while (i < 100) { md5.update('12345678901234567890123456789012345678901234567890'); i++; @@ -47,17 +47,17 @@ describe('algo-md5-test', () => { }); test('testInputIntegrity', () => { - const message = C.lib.WordArray.create([0x12345678]); + const message =new C.lib.WordArray([0x12345678]); const expected = message.toString(); C.MD5(message); expect(message.toString()).toBe(expected); }); test('testHelper', () => { - expect(C.MD5('').toString()).toBe(C.algo.MD5.create().finalize('').toString()); + expect(C.MD5('').toString()).toBe(new C.algo.MD5().finalize('').toString()); }); test('testHmacHelper', () => { - expect(C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe(C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + expect(C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe(new C.algo.HMAC(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); }); }); \ No newline at end of file