Skip to content

Instantly share code, notes, and snippets.

View LabunskyA's full-sized avatar
💭
Doing useless research

Labunsky Artem LabunskyA

💭
Doing useless research
View GitHub Profile
@artjomb
artjomb / CryptoJS_byteArrayWordArrayConversions.js
Last active January 9, 2024 16:43
Convert a byte array to a word array and back in CryptoJS-compatible fashion
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);
}