react-likert-scale
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -10,8 +10,14 @@ Changelog | ||
[Unreleased] | ||
[2.0.2] - 2021-01-13 | ||
---------------------------- | ||
_Future work will be shown here._ | ||
### Changed | ||
The Rollup configuration needed to be fixed to export the code correctly. Versions 2.0.0 and 2.0.1 | ||
were broken. Hopefully this version will be better. :) | ||
### Deleted | ||
This package no longer generates an ES Module. Instead, the component is now just a UMD modules. | ||
[2.0.1] - 2021-01-11 | ||
@@ -18,0 +24,0 @@ ---------------------------- |
import React, { useState, useEffect } from 'react'; | ||
import require$$0 from 'crypto'; | ||
@@ -22,4 +21,2 @@ function _extends() { | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn) { | ||
@@ -30,6 +27,2 @@ var module = { exports: {} }; | ||
function commonjsRequire (target) { | ||
throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.'); | ||
} | ||
/*! | ||
@@ -85,939 +78,319 @@ Copyright (c) 2017 Jed Watson. | ||
var core = createCommonjsModule(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(); | ||
} | ||
}(commonjsGlobal, function () { | ||
var crypt = createCommonjsModule(function (module) { | ||
(function() { | ||
var base64map | ||
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', | ||
/*globals window, global, require*/ | ||
crypt = { | ||
// Bit-wise rotation left | ||
rotl: function(n, b) { | ||
return (n << b) | (n >>> (32 - b)); | ||
}, | ||
/** | ||
* CryptoJS core components. | ||
*/ | ||
var CryptoJS = CryptoJS || (function (Math, undefined$1) { | ||
// Bit-wise rotation right | ||
rotr: function(n, b) { | ||
return (n << (32 - b)) | (n >>> b); | ||
}, | ||
var crypto; | ||
// Swap big-endian to little-endian and vice versa | ||
endian: function(n) { | ||
// If number given, swap endian | ||
if (n.constructor == Number) { | ||
return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00; | ||
} | ||
// Native crypto from window (Browser) | ||
if (typeof window !== 'undefined' && window.crypto) { | ||
crypto = window.crypto; | ||
} | ||
// Else, assume array and swap all items | ||
for (var i = 0; i < n.length; i++) | ||
n[i] = crypt.endian(n[i]); | ||
return n; | ||
}, | ||
// Native (experimental IE 11) crypto from window (Browser) | ||
if (!crypto && typeof window !== 'undefined' && window.msCrypto) { | ||
crypto = window.msCrypto; | ||
} | ||
// Generate an array of any length of random bytes | ||
randomBytes: function(n) { | ||
for (var bytes = []; n > 0; n--) | ||
bytes.push(Math.floor(Math.random() * 256)); | ||
return bytes; | ||
}, | ||
// Native crypto from global (NodeJS) | ||
if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) { | ||
crypto = commonjsGlobal.crypto; | ||
} | ||
// Convert a byte array to big-endian 32-bit words | ||
bytesToWords: function(bytes) { | ||
for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8) | ||
words[b >>> 5] |= bytes[i] << (24 - b % 32); | ||
return words; | ||
}, | ||
// Native crypto import via require (NodeJS) | ||
if (!crypto && typeof commonjsRequire === 'function') { | ||
try { | ||
crypto = require$$0; | ||
} catch (err) {} | ||
} | ||
// Convert big-endian 32-bit words to a byte array | ||
wordsToBytes: function(words) { | ||
for (var bytes = [], b = 0; b < words.length * 32; b += 8) | ||
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF); | ||
return bytes; | ||
}, | ||
/* | ||
* Cryptographically secure pseudorandom number generator | ||
* | ||
* As Math.random() is cryptographically not safe to use | ||
*/ | ||
var cryptoSecureRandomInt = function () { | ||
if (crypto) { | ||
// Use getRandomValues method (Browser) | ||
if (typeof crypto.getRandomValues === 'function') { | ||
try { | ||
return crypto.getRandomValues(new Uint32Array(1))[0]; | ||
} catch (err) {} | ||
} | ||
// Convert a byte array to a hex string | ||
bytesToHex: function(bytes) { | ||
for (var hex = [], i = 0; i < bytes.length; i++) { | ||
hex.push((bytes[i] >>> 4).toString(16)); | ||
hex.push((bytes[i] & 0xF).toString(16)); | ||
} | ||
return hex.join(''); | ||
}, | ||
// Use randomBytes method (NodeJS) | ||
if (typeof crypto.randomBytes === 'function') { | ||
try { | ||
return crypto.randomBytes(4).readInt32LE(); | ||
} catch (err) {} | ||
} | ||
} | ||
// Convert a hex string to a byte array | ||
hexToBytes: function(hex) { | ||
for (var bytes = [], c = 0; c < hex.length; c += 2) | ||
bytes.push(parseInt(hex.substr(c, 2), 16)); | ||
return bytes; | ||
}, | ||
throw new Error('Native crypto module could not be used to get secure random number.'); | ||
}; | ||
// Convert a byte array to a base-64 string | ||
bytesToBase64: function(bytes) { | ||
for (var base64 = [], i = 0; i < bytes.length; i += 3) { | ||
var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]; | ||
for (var j = 0; j < 4; j++) | ||
if (i * 8 + j * 6 <= bytes.length * 8) | ||
base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F)); | ||
else | ||
base64.push('='); | ||
} | ||
return base64.join(''); | ||
}, | ||
/* | ||
* Local polyfill of Object.create | ||
// Convert a base-64 string to a byte array | ||
base64ToBytes: function(base64) { | ||
// Remove non-base-64 characters | ||
base64 = base64.replace(/[^A-Z0-9+\/]/ig, ''); | ||
*/ | ||
var create = Object.create || (function () { | ||
function F() {} | ||
for (var bytes = [], i = 0, imod4 = 0; i < base64.length; | ||
imod4 = ++i % 4) { | ||
if (imod4 == 0) continue; | ||
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) | ||
& (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2)) | ||
| (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2))); | ||
} | ||
return bytes; | ||
} | ||
}; | ||
return function (obj) { | ||
var subtype; | ||
module.exports = crypt; | ||
})(); | ||
}); | ||
F.prototype = obj; | ||
var charenc = { | ||
// UTF-8 encoding | ||
utf8: { | ||
// Convert a string to a byte array | ||
stringToBytes: function(str) { | ||
return charenc.bin.stringToBytes(unescape(encodeURIComponent(str))); | ||
}, | ||
subtype = new F(); | ||
// Convert a byte array to a string | ||
bytesToString: function(bytes) { | ||
return decodeURIComponent(escape(charenc.bin.bytesToString(bytes))); | ||
} | ||
}, | ||
F.prototype = null; | ||
// Binary encoding | ||
bin: { | ||
// Convert a string to a byte array | ||
stringToBytes: function(str) { | ||
for (var bytes = [], i = 0; i < str.length; i++) | ||
bytes.push(str.charCodeAt(i) & 0xFF); | ||
return bytes; | ||
}, | ||
return subtype; | ||
}; | ||
}()); | ||
// Convert a byte array to a string | ||
bytesToString: function(bytes) { | ||
for (var str = [], i = 0; i < bytes.length; i++) | ||
str.push(String.fromCharCode(bytes[i])); | ||
return str.join(''); | ||
} | ||
} | ||
}; | ||
/** | ||
* CryptoJS namespace. | ||
*/ | ||
var C = {}; | ||
var charenc_1 = charenc; | ||
/** | ||
* Library namespace. | ||
*/ | ||
var C_lib = C.lib = {}; | ||
/*! | ||
* Determine if an object is a Buffer | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
// The _isBuffer check is for Safari 5-7 support, because it's missing | ||
// Object.prototype.constructor. Remove this eventually | ||
var isBuffer_1 = function (obj) { | ||
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) | ||
}; | ||
/** | ||
* Base object for prototypal inheritance. | ||
*/ | ||
var Base = C_lib.Base = (function () { | ||
function isBuffer (obj) { | ||
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) | ||
} | ||
// For Node v0.10 support. Remove this eventually. | ||
function isSlowBuffer (obj) { | ||
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) | ||
} | ||
return { | ||
/** | ||
* Creates a new object that inherits from this object. | ||
* | ||
* @param {Object} overrides Properties to copy into the new object. | ||
* | ||
* @return {Object} The new object. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* field: 'value', | ||
* | ||
* method: function () { | ||
* } | ||
* }); | ||
*/ | ||
extend: function (overrides) { | ||
// Spawn | ||
var subtype = create(this); | ||
var md5 = createCommonjsModule(function (module) { | ||
(function(){ | ||
var crypt$1 = crypt, | ||
utf8 = charenc_1.utf8, | ||
isBuffer = isBuffer_1, | ||
bin = charenc_1.bin, | ||
// Augment | ||
if (overrides) { | ||
subtype.mixIn(overrides); | ||
} | ||
// The core | ||
md5 = function (message, options) { | ||
// Convert to byte array | ||
if (message.constructor == String) | ||
if (options && options.encoding === 'binary') | ||
message = bin.stringToBytes(message); | ||
else | ||
message = utf8.stringToBytes(message); | ||
else if (isBuffer(message)) | ||
message = Array.prototype.slice.call(message, 0); | ||
else if (!Array.isArray(message) && message.constructor !== Uint8Array) | ||
message = message.toString(); | ||
// else, assume byte array already | ||
// Create default initializer | ||
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { | ||
subtype.init = function () { | ||
subtype.$super.init.apply(this, arguments); | ||
}; | ||
} | ||
var m = crypt$1.bytesToWords(message), | ||
l = message.length * 8, | ||
a = 1732584193, | ||
b = -271733879, | ||
c = -1732584194, | ||
d = 271733878; | ||
// Initializer's prototype is the subtype object | ||
subtype.init.prototype = subtype; | ||
// Swap endian | ||
for (var i = 0; i < m.length; i++) { | ||
m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF | | ||
((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00; | ||
} | ||
// Reference supertype | ||
subtype.$super = this; | ||
// Padding | ||
m[l >>> 5] |= 0x80 << (l % 32); | ||
m[(((l + 64) >>> 9) << 4) + 14] = l; | ||
return subtype; | ||
}, | ||
// Method shortcuts | ||
var FF = md5._ff, | ||
GG = md5._gg, | ||
HH = md5._hh, | ||
II = md5._ii; | ||
/** | ||
* 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(); | ||
*/ | ||
create: function () { | ||
var instance = this.extend(); | ||
instance.init.apply(instance, arguments); | ||
for (var i = 0; i < m.length; i += 16) { | ||
return instance; | ||
}, | ||
var aa = a, | ||
bb = b, | ||
cc = c, | ||
dd = d; | ||
/** | ||
* Initializes a newly created object. | ||
* Override this method to add some logic when your objects are created. | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* init: function () { | ||
* // ... | ||
* } | ||
* }); | ||
*/ | ||
init: function () { | ||
}, | ||
a = FF(a, b, c, d, m[i+ 0], 7, -680876936); | ||
d = FF(d, a, b, c, m[i+ 1], 12, -389564586); | ||
c = FF(c, d, a, b, m[i+ 2], 17, 606105819); | ||
b = FF(b, c, d, a, m[i+ 3], 22, -1044525330); | ||
a = FF(a, b, c, d, m[i+ 4], 7, -176418897); | ||
d = FF(d, a, b, c, m[i+ 5], 12, 1200080426); | ||
c = FF(c, d, a, b, m[i+ 6], 17, -1473231341); | ||
b = FF(b, c, d, a, m[i+ 7], 22, -45705983); | ||
a = FF(a, b, c, d, m[i+ 8], 7, 1770035416); | ||
d = FF(d, a, b, c, m[i+ 9], 12, -1958414417); | ||
c = FF(c, d, a, b, m[i+10], 17, -42063); | ||
b = FF(b, c, d, a, m[i+11], 22, -1990404162); | ||
a = FF(a, b, c, d, m[i+12], 7, 1804603682); | ||
d = FF(d, a, b, c, m[i+13], 12, -40341101); | ||
c = FF(c, d, a, b, m[i+14], 17, -1502002290); | ||
b = FF(b, c, d, a, m[i+15], 22, 1236535329); | ||
/** | ||
* Copies properties into this object. | ||
* | ||
* @param {Object} properties The properties to mix in. | ||
* | ||
* @example | ||
* | ||
* MyType.mixIn({ | ||
* field: 'value' | ||
* }); | ||
*/ | ||
mixIn: function (properties) { | ||
for (var propertyName in properties) { | ||
if (properties.hasOwnProperty(propertyName)) { | ||
this[propertyName] = properties[propertyName]; | ||
} | ||
} | ||
a = GG(a, b, c, d, m[i+ 1], 5, -165796510); | ||
d = GG(d, a, b, c, m[i+ 6], 9, -1069501632); | ||
c = GG(c, d, a, b, m[i+11], 14, 643717713); | ||
b = GG(b, c, d, a, m[i+ 0], 20, -373897302); | ||
a = GG(a, b, c, d, m[i+ 5], 5, -701558691); | ||
d = GG(d, a, b, c, m[i+10], 9, 38016083); | ||
c = GG(c, d, a, b, m[i+15], 14, -660478335); | ||
b = GG(b, c, d, a, m[i+ 4], 20, -405537848); | ||
a = GG(a, b, c, d, m[i+ 9], 5, 568446438); | ||
d = GG(d, a, b, c, m[i+14], 9, -1019803690); | ||
c = GG(c, d, a, b, m[i+ 3], 14, -187363961); | ||
b = GG(b, c, d, a, m[i+ 8], 20, 1163531501); | ||
a = GG(a, b, c, d, m[i+13], 5, -1444681467); | ||
d = GG(d, a, b, c, m[i+ 2], 9, -51403784); | ||
c = GG(c, d, a, b, m[i+ 7], 14, 1735328473); | ||
b = GG(b, c, d, a, m[i+12], 20, -1926607734); | ||
// IE won't copy toString using the loop above | ||
if (properties.hasOwnProperty('toString')) { | ||
this.toString = properties.toString; | ||
} | ||
}, | ||
a = HH(a, b, c, d, m[i+ 5], 4, -378558); | ||
d = HH(d, a, b, c, m[i+ 8], 11, -2022574463); | ||
c = HH(c, d, a, b, m[i+11], 16, 1839030562); | ||
b = HH(b, c, d, a, m[i+14], 23, -35309556); | ||
a = HH(a, b, c, d, m[i+ 1], 4, -1530992060); | ||
d = HH(d, a, b, c, m[i+ 4], 11, 1272893353); | ||
c = HH(c, d, a, b, m[i+ 7], 16, -155497632); | ||
b = HH(b, c, d, a, m[i+10], 23, -1094730640); | ||
a = HH(a, b, c, d, m[i+13], 4, 681279174); | ||
d = HH(d, a, b, c, m[i+ 0], 11, -358537222); | ||
c = HH(c, d, a, b, m[i+ 3], 16, -722521979); | ||
b = HH(b, c, d, a, m[i+ 6], 23, 76029189); | ||
a = HH(a, b, c, d, m[i+ 9], 4, -640364487); | ||
d = HH(d, a, b, c, m[i+12], 11, -421815835); | ||
c = HH(c, d, a, b, m[i+15], 16, 530742520); | ||
b = HH(b, c, d, a, m[i+ 2], 23, -995338651); | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = instance.clone(); | ||
*/ | ||
clone: function () { | ||
return this.init.prototype.extend(this); | ||
} | ||
}; | ||
}()); | ||
a = II(a, b, c, d, m[i+ 0], 6, -198630844); | ||
d = II(d, a, b, c, m[i+ 7], 10, 1126891415); | ||
c = II(c, d, a, b, m[i+14], 15, -1416354905); | ||
b = II(b, c, d, a, m[i+ 5], 21, -57434055); | ||
a = II(a, b, c, d, m[i+12], 6, 1700485571); | ||
d = II(d, a, b, c, m[i+ 3], 10, -1894986606); | ||
c = II(c, d, a, b, m[i+10], 15, -1051523); | ||
b = II(b, c, d, a, m[i+ 1], 21, -2054922799); | ||
a = II(a, b, c, d, m[i+ 8], 6, 1873313359); | ||
d = II(d, a, b, c, m[i+15], 10, -30611744); | ||
c = II(c, d, a, b, m[i+ 6], 15, -1560198380); | ||
b = II(b, c, d, a, m[i+13], 21, 1309151649); | ||
a = II(a, b, c, d, m[i+ 4], 6, -145523070); | ||
d = II(d, a, b, c, m[i+11], 10, -1120210379); | ||
c = II(c, d, a, b, m[i+ 2], 15, 718787259); | ||
b = II(b, c, d, a, m[i+ 9], 21, -343485551); | ||
/** | ||
* An array of 32-bit words. | ||
* | ||
* @property {Array} words The array of 32-bit words. | ||
* @property {number} sigBytes The number of significant bytes in this word array. | ||
*/ | ||
var WordArray = C_lib.WordArray = Base.extend({ | ||
/** | ||
* Initializes a newly created word array. | ||
* | ||
* @param {Array} words (Optional) An array of 32-bit words. | ||
* @param {number} sigBytes (Optional) The number of significant bytes in the words. | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.create(); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); | ||
*/ | ||
init: function (words, sigBytes) { | ||
words = this.words = words || []; | ||
a = (a + aa) >>> 0; | ||
b = (b + bb) >>> 0; | ||
c = (c + cc) >>> 0; | ||
d = (d + dd) >>> 0; | ||
} | ||
if (sigBytes != undefined$1) { | ||
this.sigBytes = sigBytes; | ||
} else { | ||
this.sigBytes = words.length * 4; | ||
} | ||
}, | ||
return crypt$1.endian([a, b, c, d]); | ||
}; | ||
/** | ||
* Converts this word array to a string. | ||
* | ||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex | ||
* | ||
* @return {string} The stringified word array. | ||
* | ||
* @example | ||
* | ||
* var string = wordArray + ''; | ||
* var string = wordArray.toString(); | ||
* var string = wordArray.toString(CryptoJS.enc.Utf8); | ||
*/ | ||
toString: function (encoder) { | ||
return (encoder || Hex).stringify(this); | ||
}, | ||
// Auxiliary functions | ||
md5._ff = function (a, b, c, d, x, s, t) { | ||
var n = a + (b & c | ~b & d) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
md5._gg = function (a, b, c, d, x, s, t) { | ||
var n = a + (b & d | c & ~d) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
md5._hh = function (a, b, c, d, x, s, t) { | ||
var n = a + (b ^ c ^ d) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
md5._ii = function (a, b, c, d, x, s, t) { | ||
var n = a + (c ^ (b | ~d)) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
/** | ||
* Concatenates a word array to this word array. | ||
* | ||
* @param {WordArray} wordArray The word array to append. | ||
* | ||
* @return {WordArray} This word array. | ||
* | ||
* @example | ||
* | ||
* wordArray1.concat(wordArray2); | ||
*/ | ||
concat: function (wordArray) { | ||
// Shortcuts | ||
var thisWords = this.words; | ||
var thatWords = wordArray.words; | ||
var thisSigBytes = this.sigBytes; | ||
var thatSigBytes = wordArray.sigBytes; | ||
// Package private blocksize | ||
md5._blocksize = 16; | ||
md5._digestsize = 16; | ||
// Clamp excess bits | ||
this.clamp(); | ||
module.exports = function (message, options) { | ||
if (message === undefined || message === null) | ||
throw new Error('Illegal argument ' + message); | ||
// Concat | ||
if (thisSigBytes % 4) { | ||
// Copy one byte at a time | ||
for (var i = 0; i < thatSigBytes; i++) { | ||
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); | ||
} | ||
} else { | ||
// Copy one word at a time | ||
for (var i = 0; i < thatSigBytes; i += 4) { | ||
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; | ||
} | ||
} | ||
this.sigBytes += thatSigBytes; | ||
var digestbytes = crypt$1.wordsToBytes(md5(message, options)); | ||
return options && options.asBytes ? digestbytes : | ||
options && options.asString ? bin.bytesToString(digestbytes) : | ||
crypt$1.bytesToHex(digestbytes); | ||
}; | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Removes insignificant bits. | ||
* | ||
* @example | ||
* | ||
* wordArray.clamp(); | ||
*/ | ||
clamp: function () { | ||
// Shortcuts | ||
var words = this.words; | ||
var sigBytes = this.sigBytes; | ||
// Clamp | ||
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); | ||
words.length = Math.ceil(sigBytes / 4); | ||
}, | ||
/** | ||
* Creates a copy of this word array. | ||
* | ||
* @return {WordArray} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = wordArray.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone.words = this.words.slice(0); | ||
return clone; | ||
}, | ||
/** | ||
* Creates a word array filled with random bytes. | ||
* | ||
* @param {number} nBytes The number of random bytes to generate. | ||
* | ||
* @return {WordArray} The random word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.random(16); | ||
*/ | ||
random: function (nBytes) { | ||
var words = []; | ||
for (var i = 0; i < nBytes; i += 4) { | ||
words.push(cryptoSecureRandomInt()); | ||
} | ||
return new WordArray.init(words, nBytes); | ||
} | ||
}); | ||
/** | ||
* Encoder namespace. | ||
*/ | ||
var C_enc = C.enc = {}; | ||
/** | ||
* Hex encoding strategy. | ||
*/ | ||
var Hex = C_enc.Hex = { | ||
/** | ||
* Converts a word array to a hex string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The hex string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var hexChars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
hexChars.push((bite >>> 4).toString(16)); | ||
hexChars.push((bite & 0x0f).toString(16)); | ||
} | ||
return hexChars.join(''); | ||
}, | ||
/** | ||
* Converts a hex string to a word array. | ||
* | ||
* @param {string} hexStr The hex string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Hex.parse(hexString); | ||
*/ | ||
parse: function (hexStr) { | ||
// Shortcut | ||
var hexStrLength = hexStr.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < hexStrLength; i += 2) { | ||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); | ||
} | ||
return new WordArray.init(words, hexStrLength / 2); | ||
} | ||
}; | ||
/** | ||
* Latin1 encoding strategy. | ||
*/ | ||
var Latin1 = C_enc.Latin1 = { | ||
/** | ||
* Converts a word array to a Latin1 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The Latin1 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var latin1Chars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
latin1Chars.push(String.fromCharCode(bite)); | ||
} | ||
return latin1Chars.join(''); | ||
}, | ||
/** | ||
* Converts a Latin1 string to a word array. | ||
* | ||
* @param {string} latin1Str The Latin1 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String); | ||
*/ | ||
parse: function (latin1Str) { | ||
// Shortcut | ||
var latin1StrLength = latin1Str.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < latin1StrLength; i++) { | ||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); | ||
} | ||
return new WordArray.init(words, latin1StrLength); | ||
} | ||
}; | ||
/** | ||
* UTF-8 encoding strategy. | ||
*/ | ||
var Utf8 = C_enc.Utf8 = { | ||
/** | ||
* Converts a word array to a UTF-8 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The UTF-8 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
try { | ||
return decodeURIComponent(escape(Latin1.stringify(wordArray))); | ||
} catch (e) { | ||
throw new Error('Malformed UTF-8 data'); | ||
} | ||
}, | ||
/** | ||
* Converts a UTF-8 string to a word array. | ||
* | ||
* @param {string} utf8Str The UTF-8 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String); | ||
*/ | ||
parse: function (utf8Str) { | ||
return Latin1.parse(unescape(encodeURIComponent(utf8Str))); | ||
} | ||
}; | ||
/** | ||
* Abstract buffered block algorithm template. | ||
* | ||
* The property blockSize must be implemented in a concrete subtype. | ||
* | ||
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 | ||
*/ | ||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ | ||
/** | ||
* Resets this block algorithm's data buffer to its initial state. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm.reset(); | ||
*/ | ||
reset: function () { | ||
// Initial values | ||
this._data = new WordArray.init(); | ||
this._nDataBytes = 0; | ||
}, | ||
/** | ||
* Adds new data to this block algorithm's buffer. | ||
* | ||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm._append('data'); | ||
* bufferedBlockAlgorithm._append(wordArray); | ||
*/ | ||
_append: function (data) { | ||
// Convert string to WordArray, else assume WordArray already | ||
if (typeof data == 'string') { | ||
data = Utf8.parse(data); | ||
} | ||
// Append | ||
this._data.concat(data); | ||
this._nDataBytes += data.sigBytes; | ||
}, | ||
/** | ||
* Processes available data blocks. | ||
* | ||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. | ||
* | ||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed. | ||
* | ||
* @return {WordArray} The processed data. | ||
* | ||
* @example | ||
* | ||
* var processedData = bufferedBlockAlgorithm._process(); | ||
* var processedData = bufferedBlockAlgorithm._process(!!'flush'); | ||
*/ | ||
_process: function (doFlush) { | ||
var processedWords; | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var dataSigBytes = data.sigBytes; | ||
var blockSize = this.blockSize; | ||
var blockSizeBytes = blockSize * 4; | ||
// Count blocks ready | ||
var nBlocksReady = dataSigBytes / blockSizeBytes; | ||
if (doFlush) { | ||
// Round up to include partial blocks | ||
nBlocksReady = Math.ceil(nBlocksReady); | ||
} else { | ||
// Round down to include only full blocks, | ||
// less the number of blocks that must remain in the buffer | ||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); | ||
} | ||
// Count words ready | ||
var nWordsReady = nBlocksReady * blockSize; | ||
// Count bytes ready | ||
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); | ||
// Process blocks | ||
if (nWordsReady) { | ||
for (var offset = 0; offset < nWordsReady; offset += blockSize) { | ||
// Perform concrete-algorithm logic | ||
this._doProcessBlock(dataWords, offset); | ||
} | ||
// Remove processed words | ||
processedWords = dataWords.splice(0, nWordsReady); | ||
data.sigBytes -= nBytesReady; | ||
} | ||
// Return processed words | ||
return new WordArray.init(processedWords, nBytesReady); | ||
}, | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = bufferedBlockAlgorithm.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone._data = this._data.clone(); | ||
return clone; | ||
}, | ||
_minBufferSize: 0 | ||
}); | ||
/** | ||
* Abstract hasher template. | ||
* | ||
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) | ||
*/ | ||
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({ | ||
/** | ||
* Configuration options. | ||
*/ | ||
cfg: Base.extend(), | ||
/** | ||
* Initializes a newly created hasher. | ||
* | ||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation. | ||
* | ||
* @example | ||
* | ||
* var hasher = CryptoJS.algo.SHA256.create(); | ||
*/ | ||
init: function (cfg) { | ||
// Apply config defaults | ||
this.cfg = this.cfg.extend(cfg); | ||
// Set initial values | ||
this.reset(); | ||
}, | ||
/** | ||
* Resets this hasher to its initial state. | ||
* | ||
* @example | ||
* | ||
* hasher.reset(); | ||
*/ | ||
reset: function () { | ||
// Reset data buffer | ||
BufferedBlockAlgorithm.reset.call(this); | ||
// Perform concrete-hasher logic | ||
this._doReset(); | ||
}, | ||
/** | ||
* Updates this hasher with a message. | ||
* | ||
* @param {WordArray|string} messageUpdate The message to append. | ||
* | ||
* @return {Hasher} This hasher. | ||
* | ||
* @example | ||
* | ||
* hasher.update('message'); | ||
* hasher.update(wordArray); | ||
*/ | ||
update: function (messageUpdate) { | ||
// Append | ||
this._append(messageUpdate); | ||
// Update the hash | ||
this._process(); | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Finalizes the hash computation. | ||
* Note that the finalize operation is effectively a destructive, read-once operation. | ||
* | ||
* @param {WordArray|string} messageUpdate (Optional) A final message update. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @example | ||
* | ||
* var hash = hasher.finalize(); | ||
* var hash = hasher.finalize('message'); | ||
* var hash = hasher.finalize(wordArray); | ||
*/ | ||
finalize: function (messageUpdate) { | ||
// Final message update | ||
if (messageUpdate) { | ||
this._append(messageUpdate); | ||
} | ||
// Perform concrete-hasher logic | ||
var hash = this._doFinalize(); | ||
return hash; | ||
}, | ||
blockSize: 512/32, | ||
/** | ||
* Creates a shortcut function to a hasher's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to create a helper for. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHelper: function (hasher) { | ||
return function (message, cfg) { | ||
return new hasher.init(cfg).finalize(message); | ||
}; | ||
}, | ||
/** | ||
* Creates a shortcut function to the HMAC's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to use in this HMAC helper. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHmacHelper: function (hasher) { | ||
return function (message, key) { | ||
return new C_algo.HMAC.init(hasher, key).finalize(message); | ||
}; | ||
} | ||
}); | ||
/** | ||
* Algorithm namespace. | ||
*/ | ||
var C_algo = C.algo = {}; | ||
return C; | ||
}(Math)); | ||
return CryptoJS; | ||
})); | ||
})(); | ||
}); | ||
var sha1 = createCommonjsModule(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(core); | ||
} | ||
}(commonjsGlobal, function (CryptoJS) { | ||
(function () { | ||
// Shortcuts | ||
var C = CryptoJS; | ||
var C_lib = C.lib; | ||
var WordArray = C_lib.WordArray; | ||
var Hasher = C_lib.Hasher; | ||
var C_algo = C.algo; | ||
// Reusable object | ||
var W = []; | ||
/** | ||
* SHA-1 hash algorithm. | ||
*/ | ||
var SHA1 = C_algo.SHA1 = Hasher.extend({ | ||
_doReset: function () { | ||
this._hash = new WordArray.init([ | ||
0x67452301, 0xefcdab89, | ||
0x98badcfe, 0x10325476, | ||
0xc3d2e1f0 | ||
]); | ||
}, | ||
_doProcessBlock: function (M, offset) { | ||
// Shortcut | ||
var H = this._hash.words; | ||
// Working variables | ||
var a = H[0]; | ||
var b = H[1]; | ||
var c = H[2]; | ||
var d = H[3]; | ||
var e = H[4]; | ||
// Computation | ||
for (var i = 0; i < 80; i++) { | ||
if (i < 16) { | ||
W[i] = M[offset + i] | 0; | ||
} else { | ||
var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; | ||
W[i] = (n << 1) | (n >>> 31); | ||
} | ||
var t = ((a << 5) | (a >>> 27)) + e + W[i]; | ||
if (i < 20) { | ||
t += ((b & c) | (~b & d)) + 0x5a827999; | ||
} else if (i < 40) { | ||
t += (b ^ c ^ d) + 0x6ed9eba1; | ||
} else if (i < 60) { | ||
t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; | ||
} else /* if (i < 80) */ { | ||
t += (b ^ c ^ d) - 0x359d3e2a; | ||
} | ||
e = d; | ||
d = c; | ||
c = (b << 30) | (b >>> 2); | ||
b = a; | ||
a = t; | ||
} | ||
// Intermediate hash value | ||
H[0] = (H[0] + a) | 0; | ||
H[1] = (H[1] + b) | 0; | ||
H[2] = (H[2] + c) | 0; | ||
H[3] = (H[3] + d) | 0; | ||
H[4] = (H[4] + e) | 0; | ||
}, | ||
_doFinalize: function () { | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var nBitsTotal = this._nDataBytes * 8; | ||
var nBitsLeft = data.sigBytes * 8; | ||
// Add padding | ||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; | ||
data.sigBytes = dataWords.length * 4; | ||
// Hash final blocks | ||
this._process(); | ||
// Return final computed hash | ||
return this._hash; | ||
}, | ||
clone: function () { | ||
var clone = Hasher.clone.call(this); | ||
clone._hash = this._hash.clone(); | ||
return clone; | ||
} | ||
}); | ||
/** | ||
* Shortcut function to the hasher's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hash = CryptoJS.SHA1('message'); | ||
* var hash = CryptoJS.SHA1(wordArray); | ||
*/ | ||
C.SHA1 = Hasher._createHelper(SHA1); | ||
/** | ||
* Shortcut function to the HMAC's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* @param {WordArray|string} key The secret key. | ||
* | ||
* @return {WordArray} The HMAC. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hmac = CryptoJS.HmacSHA1(message, key); | ||
*/ | ||
C.HmacSHA1 = Hasher._createHmacHelper(SHA1); | ||
}()); | ||
return CryptoJS.SHA1; | ||
})); | ||
}); | ||
function styleInject(css, ref) { | ||
@@ -1082,3 +455,3 @@ if ( ref === void 0 ) ref = {}; | ||
const sha = String(sha1(question)).substring(0, 7); | ||
const sha = String(md5(question)).substring(0, 7); | ||
const radios = responses.map((response, idx) => { | ||
@@ -1085,0 +458,0 @@ const uniqueKey = "".concat(sha).concat(idx); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('crypto')) : | ||
typeof define === 'function' && define.amd ? define(['react', 'crypto'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Likert = factory(global.React, global.require$$0)); | ||
}(this, (function (React, require$$0) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) : | ||
typeof define === 'function' && define.amd ? define(['react'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['react-likert-scale'] = factory(global.React)); | ||
}(this, (function (React) { 'use strict'; | ||
@@ -10,3 +10,2 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); | ||
@@ -31,4 +30,2 @@ function _extends() { | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn) { | ||
@@ -39,6 +36,2 @@ var module = { exports: {} }; | ||
function commonjsRequire (target) { | ||
throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.'); | ||
} | ||
/*! | ||
@@ -94,939 +87,319 @@ Copyright (c) 2017 Jed Watson. | ||
var core = createCommonjsModule(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(); | ||
} | ||
}(commonjsGlobal, function () { | ||
var crypt = createCommonjsModule(function (module) { | ||
(function() { | ||
var base64map | ||
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', | ||
/*globals window, global, require*/ | ||
crypt = { | ||
// Bit-wise rotation left | ||
rotl: function(n, b) { | ||
return (n << b) | (n >>> (32 - b)); | ||
}, | ||
/** | ||
* CryptoJS core components. | ||
*/ | ||
var CryptoJS = CryptoJS || (function (Math, undefined$1) { | ||
// Bit-wise rotation right | ||
rotr: function(n, b) { | ||
return (n << (32 - b)) | (n >>> b); | ||
}, | ||
var crypto; | ||
// Swap big-endian to little-endian and vice versa | ||
endian: function(n) { | ||
// If number given, swap endian | ||
if (n.constructor == Number) { | ||
return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00; | ||
} | ||
// Native crypto from window (Browser) | ||
if (typeof window !== 'undefined' && window.crypto) { | ||
crypto = window.crypto; | ||
} | ||
// Else, assume array and swap all items | ||
for (var i = 0; i < n.length; i++) | ||
n[i] = crypt.endian(n[i]); | ||
return n; | ||
}, | ||
// Native (experimental IE 11) crypto from window (Browser) | ||
if (!crypto && typeof window !== 'undefined' && window.msCrypto) { | ||
crypto = window.msCrypto; | ||
} | ||
// Generate an array of any length of random bytes | ||
randomBytes: function(n) { | ||
for (var bytes = []; n > 0; n--) | ||
bytes.push(Math.floor(Math.random() * 256)); | ||
return bytes; | ||
}, | ||
// Native crypto from global (NodeJS) | ||
if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) { | ||
crypto = commonjsGlobal.crypto; | ||
} | ||
// Convert a byte array to big-endian 32-bit words | ||
bytesToWords: function(bytes) { | ||
for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8) | ||
words[b >>> 5] |= bytes[i] << (24 - b % 32); | ||
return words; | ||
}, | ||
// Native crypto import via require (NodeJS) | ||
if (!crypto && typeof commonjsRequire === 'function') { | ||
try { | ||
crypto = require$$0__default['default']; | ||
} catch (err) {} | ||
} | ||
// Convert big-endian 32-bit words to a byte array | ||
wordsToBytes: function(words) { | ||
for (var bytes = [], b = 0; b < words.length * 32; b += 8) | ||
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF); | ||
return bytes; | ||
}, | ||
/* | ||
* Cryptographically secure pseudorandom number generator | ||
* | ||
* As Math.random() is cryptographically not safe to use | ||
*/ | ||
var cryptoSecureRandomInt = function () { | ||
if (crypto) { | ||
// Use getRandomValues method (Browser) | ||
if (typeof crypto.getRandomValues === 'function') { | ||
try { | ||
return crypto.getRandomValues(new Uint32Array(1))[0]; | ||
} catch (err) {} | ||
} | ||
// Convert a byte array to a hex string | ||
bytesToHex: function(bytes) { | ||
for (var hex = [], i = 0; i < bytes.length; i++) { | ||
hex.push((bytes[i] >>> 4).toString(16)); | ||
hex.push((bytes[i] & 0xF).toString(16)); | ||
} | ||
return hex.join(''); | ||
}, | ||
// Use randomBytes method (NodeJS) | ||
if (typeof crypto.randomBytes === 'function') { | ||
try { | ||
return crypto.randomBytes(4).readInt32LE(); | ||
} catch (err) {} | ||
} | ||
} | ||
// Convert a hex string to a byte array | ||
hexToBytes: function(hex) { | ||
for (var bytes = [], c = 0; c < hex.length; c += 2) | ||
bytes.push(parseInt(hex.substr(c, 2), 16)); | ||
return bytes; | ||
}, | ||
throw new Error('Native crypto module could not be used to get secure random number.'); | ||
}; | ||
// Convert a byte array to a base-64 string | ||
bytesToBase64: function(bytes) { | ||
for (var base64 = [], i = 0; i < bytes.length; i += 3) { | ||
var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]; | ||
for (var j = 0; j < 4; j++) | ||
if (i * 8 + j * 6 <= bytes.length * 8) | ||
base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F)); | ||
else | ||
base64.push('='); | ||
} | ||
return base64.join(''); | ||
}, | ||
/* | ||
* Local polyfill of Object.create | ||
// Convert a base-64 string to a byte array | ||
base64ToBytes: function(base64) { | ||
// Remove non-base-64 characters | ||
base64 = base64.replace(/[^A-Z0-9+\/]/ig, ''); | ||
*/ | ||
var create = Object.create || (function () { | ||
function F() {} | ||
for (var bytes = [], i = 0, imod4 = 0; i < base64.length; | ||
imod4 = ++i % 4) { | ||
if (imod4 == 0) continue; | ||
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) | ||
& (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2)) | ||
| (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2))); | ||
} | ||
return bytes; | ||
} | ||
}; | ||
return function (obj) { | ||
var subtype; | ||
module.exports = crypt; | ||
})(); | ||
}); | ||
F.prototype = obj; | ||
var charenc = { | ||
// UTF-8 encoding | ||
utf8: { | ||
// Convert a string to a byte array | ||
stringToBytes: function(str) { | ||
return charenc.bin.stringToBytes(unescape(encodeURIComponent(str))); | ||
}, | ||
subtype = new F(); | ||
// Convert a byte array to a string | ||
bytesToString: function(bytes) { | ||
return decodeURIComponent(escape(charenc.bin.bytesToString(bytes))); | ||
} | ||
}, | ||
F.prototype = null; | ||
// Binary encoding | ||
bin: { | ||
// Convert a string to a byte array | ||
stringToBytes: function(str) { | ||
for (var bytes = [], i = 0; i < str.length; i++) | ||
bytes.push(str.charCodeAt(i) & 0xFF); | ||
return bytes; | ||
}, | ||
return subtype; | ||
}; | ||
}()); | ||
// Convert a byte array to a string | ||
bytesToString: function(bytes) { | ||
for (var str = [], i = 0; i < bytes.length; i++) | ||
str.push(String.fromCharCode(bytes[i])); | ||
return str.join(''); | ||
} | ||
} | ||
}; | ||
/** | ||
* CryptoJS namespace. | ||
*/ | ||
var C = {}; | ||
var charenc_1 = charenc; | ||
/** | ||
* Library namespace. | ||
*/ | ||
var C_lib = C.lib = {}; | ||
/*! | ||
* Determine if an object is a Buffer | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
// The _isBuffer check is for Safari 5-7 support, because it's missing | ||
// Object.prototype.constructor. Remove this eventually | ||
var isBuffer_1 = function (obj) { | ||
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) | ||
}; | ||
/** | ||
* Base object for prototypal inheritance. | ||
*/ | ||
var Base = C_lib.Base = (function () { | ||
function isBuffer (obj) { | ||
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) | ||
} | ||
// For Node v0.10 support. Remove this eventually. | ||
function isSlowBuffer (obj) { | ||
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) | ||
} | ||
return { | ||
/** | ||
* Creates a new object that inherits from this object. | ||
* | ||
* @param {Object} overrides Properties to copy into the new object. | ||
* | ||
* @return {Object} The new object. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* field: 'value', | ||
* | ||
* method: function () { | ||
* } | ||
* }); | ||
*/ | ||
extend: function (overrides) { | ||
// Spawn | ||
var subtype = create(this); | ||
var md5 = createCommonjsModule(function (module) { | ||
(function(){ | ||
var crypt$1 = crypt, | ||
utf8 = charenc_1.utf8, | ||
isBuffer = isBuffer_1, | ||
bin = charenc_1.bin, | ||
// Augment | ||
if (overrides) { | ||
subtype.mixIn(overrides); | ||
} | ||
// The core | ||
md5 = function (message, options) { | ||
// Convert to byte array | ||
if (message.constructor == String) | ||
if (options && options.encoding === 'binary') | ||
message = bin.stringToBytes(message); | ||
else | ||
message = utf8.stringToBytes(message); | ||
else if (isBuffer(message)) | ||
message = Array.prototype.slice.call(message, 0); | ||
else if (!Array.isArray(message) && message.constructor !== Uint8Array) | ||
message = message.toString(); | ||
// else, assume byte array already | ||
// Create default initializer | ||
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { | ||
subtype.init = function () { | ||
subtype.$super.init.apply(this, arguments); | ||
}; | ||
} | ||
var m = crypt$1.bytesToWords(message), | ||
l = message.length * 8, | ||
a = 1732584193, | ||
b = -271733879, | ||
c = -1732584194, | ||
d = 271733878; | ||
// Initializer's prototype is the subtype object | ||
subtype.init.prototype = subtype; | ||
// Swap endian | ||
for (var i = 0; i < m.length; i++) { | ||
m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF | | ||
((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00; | ||
} | ||
// Reference supertype | ||
subtype.$super = this; | ||
// Padding | ||
m[l >>> 5] |= 0x80 << (l % 32); | ||
m[(((l + 64) >>> 9) << 4) + 14] = l; | ||
return subtype; | ||
}, | ||
// Method shortcuts | ||
var FF = md5._ff, | ||
GG = md5._gg, | ||
HH = md5._hh, | ||
II = md5._ii; | ||
/** | ||
* 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(); | ||
*/ | ||
create: function () { | ||
var instance = this.extend(); | ||
instance.init.apply(instance, arguments); | ||
for (var i = 0; i < m.length; i += 16) { | ||
return instance; | ||
}, | ||
var aa = a, | ||
bb = b, | ||
cc = c, | ||
dd = d; | ||
/** | ||
* Initializes a newly created object. | ||
* Override this method to add some logic when your objects are created. | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* init: function () { | ||
* // ... | ||
* } | ||
* }); | ||
*/ | ||
init: function () { | ||
}, | ||
a = FF(a, b, c, d, m[i+ 0], 7, -680876936); | ||
d = FF(d, a, b, c, m[i+ 1], 12, -389564586); | ||
c = FF(c, d, a, b, m[i+ 2], 17, 606105819); | ||
b = FF(b, c, d, a, m[i+ 3], 22, -1044525330); | ||
a = FF(a, b, c, d, m[i+ 4], 7, -176418897); | ||
d = FF(d, a, b, c, m[i+ 5], 12, 1200080426); | ||
c = FF(c, d, a, b, m[i+ 6], 17, -1473231341); | ||
b = FF(b, c, d, a, m[i+ 7], 22, -45705983); | ||
a = FF(a, b, c, d, m[i+ 8], 7, 1770035416); | ||
d = FF(d, a, b, c, m[i+ 9], 12, -1958414417); | ||
c = FF(c, d, a, b, m[i+10], 17, -42063); | ||
b = FF(b, c, d, a, m[i+11], 22, -1990404162); | ||
a = FF(a, b, c, d, m[i+12], 7, 1804603682); | ||
d = FF(d, a, b, c, m[i+13], 12, -40341101); | ||
c = FF(c, d, a, b, m[i+14], 17, -1502002290); | ||
b = FF(b, c, d, a, m[i+15], 22, 1236535329); | ||
/** | ||
* Copies properties into this object. | ||
* | ||
* @param {Object} properties The properties to mix in. | ||
* | ||
* @example | ||
* | ||
* MyType.mixIn({ | ||
* field: 'value' | ||
* }); | ||
*/ | ||
mixIn: function (properties) { | ||
for (var propertyName in properties) { | ||
if (properties.hasOwnProperty(propertyName)) { | ||
this[propertyName] = properties[propertyName]; | ||
} | ||
} | ||
a = GG(a, b, c, d, m[i+ 1], 5, -165796510); | ||
d = GG(d, a, b, c, m[i+ 6], 9, -1069501632); | ||
c = GG(c, d, a, b, m[i+11], 14, 643717713); | ||
b = GG(b, c, d, a, m[i+ 0], 20, -373897302); | ||
a = GG(a, b, c, d, m[i+ 5], 5, -701558691); | ||
d = GG(d, a, b, c, m[i+10], 9, 38016083); | ||
c = GG(c, d, a, b, m[i+15], 14, -660478335); | ||
b = GG(b, c, d, a, m[i+ 4], 20, -405537848); | ||
a = GG(a, b, c, d, m[i+ 9], 5, 568446438); | ||
d = GG(d, a, b, c, m[i+14], 9, -1019803690); | ||
c = GG(c, d, a, b, m[i+ 3], 14, -187363961); | ||
b = GG(b, c, d, a, m[i+ 8], 20, 1163531501); | ||
a = GG(a, b, c, d, m[i+13], 5, -1444681467); | ||
d = GG(d, a, b, c, m[i+ 2], 9, -51403784); | ||
c = GG(c, d, a, b, m[i+ 7], 14, 1735328473); | ||
b = GG(b, c, d, a, m[i+12], 20, -1926607734); | ||
// IE won't copy toString using the loop above | ||
if (properties.hasOwnProperty('toString')) { | ||
this.toString = properties.toString; | ||
} | ||
}, | ||
a = HH(a, b, c, d, m[i+ 5], 4, -378558); | ||
d = HH(d, a, b, c, m[i+ 8], 11, -2022574463); | ||
c = HH(c, d, a, b, m[i+11], 16, 1839030562); | ||
b = HH(b, c, d, a, m[i+14], 23, -35309556); | ||
a = HH(a, b, c, d, m[i+ 1], 4, -1530992060); | ||
d = HH(d, a, b, c, m[i+ 4], 11, 1272893353); | ||
c = HH(c, d, a, b, m[i+ 7], 16, -155497632); | ||
b = HH(b, c, d, a, m[i+10], 23, -1094730640); | ||
a = HH(a, b, c, d, m[i+13], 4, 681279174); | ||
d = HH(d, a, b, c, m[i+ 0], 11, -358537222); | ||
c = HH(c, d, a, b, m[i+ 3], 16, -722521979); | ||
b = HH(b, c, d, a, m[i+ 6], 23, 76029189); | ||
a = HH(a, b, c, d, m[i+ 9], 4, -640364487); | ||
d = HH(d, a, b, c, m[i+12], 11, -421815835); | ||
c = HH(c, d, a, b, m[i+15], 16, 530742520); | ||
b = HH(b, c, d, a, m[i+ 2], 23, -995338651); | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = instance.clone(); | ||
*/ | ||
clone: function () { | ||
return this.init.prototype.extend(this); | ||
} | ||
}; | ||
}()); | ||
a = II(a, b, c, d, m[i+ 0], 6, -198630844); | ||
d = II(d, a, b, c, m[i+ 7], 10, 1126891415); | ||
c = II(c, d, a, b, m[i+14], 15, -1416354905); | ||
b = II(b, c, d, a, m[i+ 5], 21, -57434055); | ||
a = II(a, b, c, d, m[i+12], 6, 1700485571); | ||
d = II(d, a, b, c, m[i+ 3], 10, -1894986606); | ||
c = II(c, d, a, b, m[i+10], 15, -1051523); | ||
b = II(b, c, d, a, m[i+ 1], 21, -2054922799); | ||
a = II(a, b, c, d, m[i+ 8], 6, 1873313359); | ||
d = II(d, a, b, c, m[i+15], 10, -30611744); | ||
c = II(c, d, a, b, m[i+ 6], 15, -1560198380); | ||
b = II(b, c, d, a, m[i+13], 21, 1309151649); | ||
a = II(a, b, c, d, m[i+ 4], 6, -145523070); | ||
d = II(d, a, b, c, m[i+11], 10, -1120210379); | ||
c = II(c, d, a, b, m[i+ 2], 15, 718787259); | ||
b = II(b, c, d, a, m[i+ 9], 21, -343485551); | ||
/** | ||
* An array of 32-bit words. | ||
* | ||
* @property {Array} words The array of 32-bit words. | ||
* @property {number} sigBytes The number of significant bytes in this word array. | ||
*/ | ||
var WordArray = C_lib.WordArray = Base.extend({ | ||
/** | ||
* Initializes a newly created word array. | ||
* | ||
* @param {Array} words (Optional) An array of 32-bit words. | ||
* @param {number} sigBytes (Optional) The number of significant bytes in the words. | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.create(); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); | ||
*/ | ||
init: function (words, sigBytes) { | ||
words = this.words = words || []; | ||
a = (a + aa) >>> 0; | ||
b = (b + bb) >>> 0; | ||
c = (c + cc) >>> 0; | ||
d = (d + dd) >>> 0; | ||
} | ||
if (sigBytes != undefined$1) { | ||
this.sigBytes = sigBytes; | ||
} else { | ||
this.sigBytes = words.length * 4; | ||
} | ||
}, | ||
return crypt$1.endian([a, b, c, d]); | ||
}; | ||
/** | ||
* Converts this word array to a string. | ||
* | ||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex | ||
* | ||
* @return {string} The stringified word array. | ||
* | ||
* @example | ||
* | ||
* var string = wordArray + ''; | ||
* var string = wordArray.toString(); | ||
* var string = wordArray.toString(CryptoJS.enc.Utf8); | ||
*/ | ||
toString: function (encoder) { | ||
return (encoder || Hex).stringify(this); | ||
}, | ||
// Auxiliary functions | ||
md5._ff = function (a, b, c, d, x, s, t) { | ||
var n = a + (b & c | ~b & d) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
md5._gg = function (a, b, c, d, x, s, t) { | ||
var n = a + (b & d | c & ~d) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
md5._hh = function (a, b, c, d, x, s, t) { | ||
var n = a + (b ^ c ^ d) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
md5._ii = function (a, b, c, d, x, s, t) { | ||
var n = a + (c ^ (b | ~d)) + (x >>> 0) + t; | ||
return ((n << s) | (n >>> (32 - s))) + b; | ||
}; | ||
/** | ||
* Concatenates a word array to this word array. | ||
* | ||
* @param {WordArray} wordArray The word array to append. | ||
* | ||
* @return {WordArray} This word array. | ||
* | ||
* @example | ||
* | ||
* wordArray1.concat(wordArray2); | ||
*/ | ||
concat: function (wordArray) { | ||
// Shortcuts | ||
var thisWords = this.words; | ||
var thatWords = wordArray.words; | ||
var thisSigBytes = this.sigBytes; | ||
var thatSigBytes = wordArray.sigBytes; | ||
// Package private blocksize | ||
md5._blocksize = 16; | ||
md5._digestsize = 16; | ||
// Clamp excess bits | ||
this.clamp(); | ||
module.exports = function (message, options) { | ||
if (message === undefined || message === null) | ||
throw new Error('Illegal argument ' + message); | ||
// Concat | ||
if (thisSigBytes % 4) { | ||
// Copy one byte at a time | ||
for (var i = 0; i < thatSigBytes; i++) { | ||
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); | ||
} | ||
} else { | ||
// Copy one word at a time | ||
for (var i = 0; i < thatSigBytes; i += 4) { | ||
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; | ||
} | ||
} | ||
this.sigBytes += thatSigBytes; | ||
var digestbytes = crypt$1.wordsToBytes(md5(message, options)); | ||
return options && options.asBytes ? digestbytes : | ||
options && options.asString ? bin.bytesToString(digestbytes) : | ||
crypt$1.bytesToHex(digestbytes); | ||
}; | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Removes insignificant bits. | ||
* | ||
* @example | ||
* | ||
* wordArray.clamp(); | ||
*/ | ||
clamp: function () { | ||
// Shortcuts | ||
var words = this.words; | ||
var sigBytes = this.sigBytes; | ||
// Clamp | ||
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); | ||
words.length = Math.ceil(sigBytes / 4); | ||
}, | ||
/** | ||
* Creates a copy of this word array. | ||
* | ||
* @return {WordArray} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = wordArray.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone.words = this.words.slice(0); | ||
return clone; | ||
}, | ||
/** | ||
* Creates a word array filled with random bytes. | ||
* | ||
* @param {number} nBytes The number of random bytes to generate. | ||
* | ||
* @return {WordArray} The random word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.random(16); | ||
*/ | ||
random: function (nBytes) { | ||
var words = []; | ||
for (var i = 0; i < nBytes; i += 4) { | ||
words.push(cryptoSecureRandomInt()); | ||
} | ||
return new WordArray.init(words, nBytes); | ||
} | ||
}); | ||
/** | ||
* Encoder namespace. | ||
*/ | ||
var C_enc = C.enc = {}; | ||
/** | ||
* Hex encoding strategy. | ||
*/ | ||
var Hex = C_enc.Hex = { | ||
/** | ||
* Converts a word array to a hex string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The hex string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var hexChars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
hexChars.push((bite >>> 4).toString(16)); | ||
hexChars.push((bite & 0x0f).toString(16)); | ||
} | ||
return hexChars.join(''); | ||
}, | ||
/** | ||
* Converts a hex string to a word array. | ||
* | ||
* @param {string} hexStr The hex string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Hex.parse(hexString); | ||
*/ | ||
parse: function (hexStr) { | ||
// Shortcut | ||
var hexStrLength = hexStr.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < hexStrLength; i += 2) { | ||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); | ||
} | ||
return new WordArray.init(words, hexStrLength / 2); | ||
} | ||
}; | ||
/** | ||
* Latin1 encoding strategy. | ||
*/ | ||
var Latin1 = C_enc.Latin1 = { | ||
/** | ||
* Converts a word array to a Latin1 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The Latin1 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var latin1Chars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
latin1Chars.push(String.fromCharCode(bite)); | ||
} | ||
return latin1Chars.join(''); | ||
}, | ||
/** | ||
* Converts a Latin1 string to a word array. | ||
* | ||
* @param {string} latin1Str The Latin1 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String); | ||
*/ | ||
parse: function (latin1Str) { | ||
// Shortcut | ||
var latin1StrLength = latin1Str.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < latin1StrLength; i++) { | ||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); | ||
} | ||
return new WordArray.init(words, latin1StrLength); | ||
} | ||
}; | ||
/** | ||
* UTF-8 encoding strategy. | ||
*/ | ||
var Utf8 = C_enc.Utf8 = { | ||
/** | ||
* Converts a word array to a UTF-8 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The UTF-8 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
try { | ||
return decodeURIComponent(escape(Latin1.stringify(wordArray))); | ||
} catch (e) { | ||
throw new Error('Malformed UTF-8 data'); | ||
} | ||
}, | ||
/** | ||
* Converts a UTF-8 string to a word array. | ||
* | ||
* @param {string} utf8Str The UTF-8 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String); | ||
*/ | ||
parse: function (utf8Str) { | ||
return Latin1.parse(unescape(encodeURIComponent(utf8Str))); | ||
} | ||
}; | ||
/** | ||
* Abstract buffered block algorithm template. | ||
* | ||
* The property blockSize must be implemented in a concrete subtype. | ||
* | ||
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 | ||
*/ | ||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ | ||
/** | ||
* Resets this block algorithm's data buffer to its initial state. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm.reset(); | ||
*/ | ||
reset: function () { | ||
// Initial values | ||
this._data = new WordArray.init(); | ||
this._nDataBytes = 0; | ||
}, | ||
/** | ||
* Adds new data to this block algorithm's buffer. | ||
* | ||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm._append('data'); | ||
* bufferedBlockAlgorithm._append(wordArray); | ||
*/ | ||
_append: function (data) { | ||
// Convert string to WordArray, else assume WordArray already | ||
if (typeof data == 'string') { | ||
data = Utf8.parse(data); | ||
} | ||
// Append | ||
this._data.concat(data); | ||
this._nDataBytes += data.sigBytes; | ||
}, | ||
/** | ||
* Processes available data blocks. | ||
* | ||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. | ||
* | ||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed. | ||
* | ||
* @return {WordArray} The processed data. | ||
* | ||
* @example | ||
* | ||
* var processedData = bufferedBlockAlgorithm._process(); | ||
* var processedData = bufferedBlockAlgorithm._process(!!'flush'); | ||
*/ | ||
_process: function (doFlush) { | ||
var processedWords; | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var dataSigBytes = data.sigBytes; | ||
var blockSize = this.blockSize; | ||
var blockSizeBytes = blockSize * 4; | ||
// Count blocks ready | ||
var nBlocksReady = dataSigBytes / blockSizeBytes; | ||
if (doFlush) { | ||
// Round up to include partial blocks | ||
nBlocksReady = Math.ceil(nBlocksReady); | ||
} else { | ||
// Round down to include only full blocks, | ||
// less the number of blocks that must remain in the buffer | ||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); | ||
} | ||
// Count words ready | ||
var nWordsReady = nBlocksReady * blockSize; | ||
// Count bytes ready | ||
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); | ||
// Process blocks | ||
if (nWordsReady) { | ||
for (var offset = 0; offset < nWordsReady; offset += blockSize) { | ||
// Perform concrete-algorithm logic | ||
this._doProcessBlock(dataWords, offset); | ||
} | ||
// Remove processed words | ||
processedWords = dataWords.splice(0, nWordsReady); | ||
data.sigBytes -= nBytesReady; | ||
} | ||
// Return processed words | ||
return new WordArray.init(processedWords, nBytesReady); | ||
}, | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = bufferedBlockAlgorithm.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone._data = this._data.clone(); | ||
return clone; | ||
}, | ||
_minBufferSize: 0 | ||
}); | ||
/** | ||
* Abstract hasher template. | ||
* | ||
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) | ||
*/ | ||
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({ | ||
/** | ||
* Configuration options. | ||
*/ | ||
cfg: Base.extend(), | ||
/** | ||
* Initializes a newly created hasher. | ||
* | ||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation. | ||
* | ||
* @example | ||
* | ||
* var hasher = CryptoJS.algo.SHA256.create(); | ||
*/ | ||
init: function (cfg) { | ||
// Apply config defaults | ||
this.cfg = this.cfg.extend(cfg); | ||
// Set initial values | ||
this.reset(); | ||
}, | ||
/** | ||
* Resets this hasher to its initial state. | ||
* | ||
* @example | ||
* | ||
* hasher.reset(); | ||
*/ | ||
reset: function () { | ||
// Reset data buffer | ||
BufferedBlockAlgorithm.reset.call(this); | ||
// Perform concrete-hasher logic | ||
this._doReset(); | ||
}, | ||
/** | ||
* Updates this hasher with a message. | ||
* | ||
* @param {WordArray|string} messageUpdate The message to append. | ||
* | ||
* @return {Hasher} This hasher. | ||
* | ||
* @example | ||
* | ||
* hasher.update('message'); | ||
* hasher.update(wordArray); | ||
*/ | ||
update: function (messageUpdate) { | ||
// Append | ||
this._append(messageUpdate); | ||
// Update the hash | ||
this._process(); | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Finalizes the hash computation. | ||
* Note that the finalize operation is effectively a destructive, read-once operation. | ||
* | ||
* @param {WordArray|string} messageUpdate (Optional) A final message update. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @example | ||
* | ||
* var hash = hasher.finalize(); | ||
* var hash = hasher.finalize('message'); | ||
* var hash = hasher.finalize(wordArray); | ||
*/ | ||
finalize: function (messageUpdate) { | ||
// Final message update | ||
if (messageUpdate) { | ||
this._append(messageUpdate); | ||
} | ||
// Perform concrete-hasher logic | ||
var hash = this._doFinalize(); | ||
return hash; | ||
}, | ||
blockSize: 512/32, | ||
/** | ||
* Creates a shortcut function to a hasher's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to create a helper for. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHelper: function (hasher) { | ||
return function (message, cfg) { | ||
return new hasher.init(cfg).finalize(message); | ||
}; | ||
}, | ||
/** | ||
* Creates a shortcut function to the HMAC's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to use in this HMAC helper. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHmacHelper: function (hasher) { | ||
return function (message, key) { | ||
return new C_algo.HMAC.init(hasher, key).finalize(message); | ||
}; | ||
} | ||
}); | ||
/** | ||
* Algorithm namespace. | ||
*/ | ||
var C_algo = C.algo = {}; | ||
return C; | ||
}(Math)); | ||
return CryptoJS; | ||
})); | ||
})(); | ||
}); | ||
var sha1 = createCommonjsModule(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(core); | ||
} | ||
}(commonjsGlobal, function (CryptoJS) { | ||
(function () { | ||
// Shortcuts | ||
var C = CryptoJS; | ||
var C_lib = C.lib; | ||
var WordArray = C_lib.WordArray; | ||
var Hasher = C_lib.Hasher; | ||
var C_algo = C.algo; | ||
// Reusable object | ||
var W = []; | ||
/** | ||
* SHA-1 hash algorithm. | ||
*/ | ||
var SHA1 = C_algo.SHA1 = Hasher.extend({ | ||
_doReset: function () { | ||
this._hash = new WordArray.init([ | ||
0x67452301, 0xefcdab89, | ||
0x98badcfe, 0x10325476, | ||
0xc3d2e1f0 | ||
]); | ||
}, | ||
_doProcessBlock: function (M, offset) { | ||
// Shortcut | ||
var H = this._hash.words; | ||
// Working variables | ||
var a = H[0]; | ||
var b = H[1]; | ||
var c = H[2]; | ||
var d = H[3]; | ||
var e = H[4]; | ||
// Computation | ||
for (var i = 0; i < 80; i++) { | ||
if (i < 16) { | ||
W[i] = M[offset + i] | 0; | ||
} else { | ||
var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; | ||
W[i] = (n << 1) | (n >>> 31); | ||
} | ||
var t = ((a << 5) | (a >>> 27)) + e + W[i]; | ||
if (i < 20) { | ||
t += ((b & c) | (~b & d)) + 0x5a827999; | ||
} else if (i < 40) { | ||
t += (b ^ c ^ d) + 0x6ed9eba1; | ||
} else if (i < 60) { | ||
t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; | ||
} else /* if (i < 80) */ { | ||
t += (b ^ c ^ d) - 0x359d3e2a; | ||
} | ||
e = d; | ||
d = c; | ||
c = (b << 30) | (b >>> 2); | ||
b = a; | ||
a = t; | ||
} | ||
// Intermediate hash value | ||
H[0] = (H[0] + a) | 0; | ||
H[1] = (H[1] + b) | 0; | ||
H[2] = (H[2] + c) | 0; | ||
H[3] = (H[3] + d) | 0; | ||
H[4] = (H[4] + e) | 0; | ||
}, | ||
_doFinalize: function () { | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var nBitsTotal = this._nDataBytes * 8; | ||
var nBitsLeft = data.sigBytes * 8; | ||
// Add padding | ||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; | ||
data.sigBytes = dataWords.length * 4; | ||
// Hash final blocks | ||
this._process(); | ||
// Return final computed hash | ||
return this._hash; | ||
}, | ||
clone: function () { | ||
var clone = Hasher.clone.call(this); | ||
clone._hash = this._hash.clone(); | ||
return clone; | ||
} | ||
}); | ||
/** | ||
* Shortcut function to the hasher's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hash = CryptoJS.SHA1('message'); | ||
* var hash = CryptoJS.SHA1(wordArray); | ||
*/ | ||
C.SHA1 = Hasher._createHelper(SHA1); | ||
/** | ||
* Shortcut function to the HMAC's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* @param {WordArray|string} key The secret key. | ||
* | ||
* @return {WordArray} The HMAC. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hmac = CryptoJS.HmacSHA1(message, key); | ||
*/ | ||
C.HmacSHA1 = Hasher._createHmacHelper(SHA1); | ||
}()); | ||
return CryptoJS.SHA1; | ||
})); | ||
}); | ||
function styleInject(css, ref) { | ||
@@ -1091,5 +464,5 @@ if ( ref === void 0 ) ref = {}; | ||
const sha = String(sha1(question)).substring(0, 7); | ||
const hash = String(md5(question)).substring(0, 7); | ||
const radios = responses.map((response, idx) => { | ||
const uniqueKey = "".concat(sha).concat(idx); | ||
const uniqueKey = "".concat(hash).concat(idx); | ||
return /*#__PURE__*/React__default['default'].createElement("label", { | ||
@@ -1106,3 +479,3 @@ key: uniqueKey, | ||
value: response.value, | ||
name: sha, | ||
name: hash, | ||
id: uniqueKey, | ||
@@ -1123,3 +496,3 @@ className: "visuallyHidden", | ||
ref: ref, | ||
id: id || sha | ||
id: id || hash | ||
}, restProps), /*#__PURE__*/React__default['default'].createElement("legend", null, question), /*#__PURE__*/React__default['default'].createElement("div", { | ||
@@ -1126,0 +499,0 @@ className: "likertBand" |
{ | ||
"name": "react-likert-scale", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A React-based Likert Scale to collect data.", | ||
"main": "dist/likert.umd.js", | ||
"module": "dist/likert.esm.js", | ||
"files": [ | ||
@@ -23,5 +22,3 @@ "dist" | ||
"start": "webpack serve --config webpack.config.dev.js --inline --hot --progress --mode development", | ||
"build:esm": "rollup -c -f esm -o dist/likert.esm.js", | ||
"build:umd": "rollup -c -f umd -g react:React -o dist/likert.umd.js", | ||
"build": "npm run build:esm && npm run build:umd", | ||
"build": "rollup --config", | ||
"prepare": "npm run build" | ||
@@ -60,4 +57,4 @@ }, | ||
"classnames": "^2.2.6", | ||
"crypto-js": "^4.0.0" | ||
"md5": "^2.3.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40246
859
1
+ Addedmd5@^2.3.0
+ Addedcharenc@0.0.2(transitive)
+ Addedcrypt@0.0.2(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedmd5@2.3.0(transitive)
- Removedcrypto-js@^4.0.0
- Removedcrypto-js@4.2.0(transitive)