Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
decryptHexToBuffer(cipher) {
assert(cipher, "Missing cipher text");
// Convert data into word arrays (used by Crypto)
var cipher_array = encHex.parse(cipher);
var plainwords = this._decrypt_word_array(cipher_array);
var plainhex = encHex.stringify(plainwords);
return new Buffer(plainhex, 'hex');
}
decryptHexToBuffer(cipher) {
assert(cipher, "Missing cipher text");
// Convert data into word arrays (used by Crypto)
var cipher_array = encHex.parse(cipher);
var plainwords = this._decrypt_word_array(cipher_array);
var plainhex = encHex.stringify(plainwords);
return new Buffer(plainhex, "hex");
}
function hash(
hex: string,
hashingFunction: (i: any) => CryptoJS.WordArray
): string {
const hexEncoded = hexEncoding.parse(hex);
const result = hashingFunction(hexEncoded);
return result.toString(hexEncoding);
}
encryptHex(plainhex) {
var plain_array = encHex.parse(plainhex);
var cipher_array = this._encrypt_word_array(plain_array);
return encHex.stringify(cipher_array);
}
}
export const hash160 = (hex) => {
if (typeof hex !== 'string') throw new Error('reverseHex expects a string')
if (hex.length % 2 !== 0) throw new Error(`Incorrect Length: ${hex}`)
let hexEncoded = hexEncoding.parse(hex)
let ProgramSha256 = SHA256(hexEncoded)
return RIPEMD160(ProgramSha256).toString()
}
static fromSha512(hash) {
assert.equal(
hash.length,
128,
`A Sha512 in HEX should be 128 characters long, instead got ${
hash.length
}`
);
var iv = encHex.parse(hash.substring(64, 96));
var key = encHex.parse(hash.substring(0, 64));
return new Aes(iv, key);
}