use native concat instead of own reimplementation

This commit is contained in:
azivner 2017-11-04 21:10:19 -04:00
parent b192336113
commit b64ef6311c

View File

@ -185,10 +185,10 @@ const encryption = (function() {
}
function encrypt(aes, str) {
const payload = aesjs.utils.utf8.toBytes(str);
const payload = Array.from(aesjs.utils.utf8.toBytes(str));
const digest = sha256Array(payload).slice(0, 4);
const digestWithPayload = concat(digest, payload);
const digestWithPayload = digest.concat(payload);
const encryptedBytes = aes.encrypt(digestWithPayload);
@ -220,20 +220,6 @@ const encryption = (function() {
return payload;
}
function concat(a, b) {
const result = [];
for (let key in a) {
result.push(a[key]);
}
for (let key in b) {
result.push(b[key]);
}
return result;
}
function sha256Array(content) {
const hash = sha256.create();
hash.update(content);