summaryrefslogtreecommitdiffstats
path: root/core/bitArray.js
diff options
context:
space:
mode:
authorSteve Thomas <Sc00bz@users.noreply.github.com>2015-11-01 14:36:28 -0600
committerSteve Thomas <Sc00bz@users.noreply.github.com>2015-11-01 14:36:28 -0600
commitdb7e40d449ab4ae65bacf267b38d1bf836b4fe54 (patch)
treef6f815673f56490c8ae3bfdc8ed9a5f4d9996f76 /core/bitArray.js
parent025908ef2b091faab75f60188654f789b691ff0d (diff)
parentf9a2494fae0dcddef493de453aa6ab69caa987cf (diff)
downloadsjcl-db7e40d449ab4ae65bacf267b38d1bf836b4fe54.zip
sjcl-db7e40d449ab4ae65bacf267b38d1bf836b4fe54.tar.gz
sjcl-db7e40d449ab4ae65bacf267b38d1bf836b4fe54.tar.bz2
Merge pull request #1 from bitwiseshiftleft/master
Update
Diffstat (limited to 'core/bitArray.js')
-rw-r--r--core/bitArray.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/bitArray.js b/core/bitArray.js
index a6d0617..54112ac 100644
--- a/core/bitArray.js
+++ b/core/bitArray.js
@@ -74,7 +74,7 @@ sjcl.bitArray = {
return a1.concat(a2);
}
- var out, i, last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
+ var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
if (shift === 32) {
return a1.concat(a2);
} else {
@@ -183,5 +183,19 @@ sjcl.bitArray = {
*/
_xor4: function(x,y) {
return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];
+ },
+
+ /** byteswap a word array inplace.
+ * (does not handle partial words)
+ * @param {sjcl.bitArray} a word array
+ * @return {sjcl.bitArray} byteswapped array
+ */
+ byteswapM: function(a) {
+ var i, v, m = 0xff00;
+ for (i = 0; i < a.length; ++i) {
+ v = a[i];
+ a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);
+ }
+ return a;
}
};