@polkadot/util-crypto
Advanced tools
Comparing version 0.15.2 to 0.15.3
{ | ||
"name": "@polkadot/util-crypto", | ||
"version": "0.15.2", | ||
"version": "0.15.3", | ||
"description": "A collection of useful crypto utilities for @polkadot", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,5 +6,5 @@ 'use strict'; | ||
// of the ISC license. See the LICENSE file for details. | ||
var hexAddPrefix = require('@polkadot/util/hex/addPrefix'); | ||
var u8aToHex = require('@polkadot/util/u8a/toHex'); | ||
var xxhash64AsRaw = require('./xxhash64/asRaw'); | ||
var xxhashAsU8a = require('./asU8a'); | ||
@@ -25,11 +25,3 @@ /** | ||
var strLength = Math.ceil(bitLength / 4); | ||
var iterations = Math.ceil(strLength / 8); | ||
var result = xxhash64AsRaw(data, 0); | ||
for (var seed = 1; seed < iterations; seed++) { | ||
result += xxhash64AsRaw(data, seed); | ||
} | ||
return hexAddPrefix(result.substr(0, strLength)); | ||
return u8aToHex(xxhashAsU8a(data, bitLength)); | ||
}; |
@@ -6,6 +6,4 @@ 'use strict'; | ||
// of the ISC license. See the LICENSE file for details. | ||
var hexToU8a = require('@polkadot/util/hex/toU8a'); | ||
var xxhash64AsBn = require('./xxhash64/asBn'); | ||
var xxhashAsHex = require('./asHex'); | ||
/** | ||
@@ -25,3 +23,11 @@ @name xxhashAsU8a | ||
return hexToU8a(xxhashAsHex(data, bitLength)); | ||
var byteLength = Math.ceil(bitLength / 8); | ||
var iterations = Math.ceil(bitLength / 64); | ||
var u8a = new Uint8Array(byteLength); | ||
for (var seed = 0; seed < iterations; seed++) { | ||
u8a.set(xxhash64AsBn(data, seed).toArray('le', 8), seed * 8); | ||
} | ||
return u8a; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86484
708