Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Doing useless research

Labunsky Artem LabunskyA

💭
Doing useless research
View GitHub Profile
@artjomb
artjomb / CryptoJS_byteArrayWordArrayConversions.js
Last active Sep 28, 2021
Convert a byte array to a word array and back in CryptoJS-compatible fashion
View CryptoJS_byteArrayWordArrayConversions.js
function byteArrayToWordArray(ba) {
var wa = [],
i;
for (i = 0; i < ba.length; i++) {
wa[(i / 4) | 0] |= ba[i] << (24 - 8 * i);
}
return CryptoJS.lib.WordArray.create(wa, ba.length);
}