mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-18 09:28:52 +01:00
Added hashCode
This commit is contained in:
parent
8472e877a4
commit
d580c35898
14
lib/hash.js
14
lib/hash.js
@ -34,6 +34,17 @@
|
||||
return hash;
|
||||
};
|
||||
|
||||
scope.hashCode = function(inputByteArray){
|
||||
var hash = new Uint32Array(1);
|
||||
var intView = new Uint32Array(inputByteArray.buffer);
|
||||
var length = intView.length;
|
||||
for (let i = 0; i < length; i += 1){
|
||||
var v = hash[0];
|
||||
hash[0] = ((v << 5) - v) + intView[i];
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
||||
scope.md5 = function(){
|
||||
function leftRotate(v, rotate){
|
||||
return v << rotate | v >>> (32 - rotate);
|
||||
@ -222,4 +233,7 @@
|
||||
scope.sumXorString = function(byteArray){
|
||||
return scope.byteArrayToString(scope.sumXor(byteArray));
|
||||
};
|
||||
scope.hashCodeString = function(byteArray){
|
||||
return String.fromCharCode(scope.hashCode(byteArray)[0]);
|
||||
};
|
||||
}());
|
Loading…
x
Reference in New Issue
Block a user