Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
hash_sha3_384.hash = function (data) {
var hashBits = sjcl.codec.hex.toBits(sha3_384(data));
return hashBits;
};
switch (scheme) {
case SignatureScheme.ECDSAwithSHA224:
return cryptoJS.SHA224(cryptoJS.enc.Hex.parse(msg)).toString();
case SignatureScheme.ECDSAwithSHA256:
return cryptoJS.SHA256(cryptoJS.enc.Hex.parse(msg)).toString();
case SignatureScheme.ECDSAwithSHA384:
return cryptoJS.SHA384(cryptoJS.enc.Hex.parse(msg)).toString();
case SignatureScheme.ECDSAwithSHA512:
case SignatureScheme.EDDSAwithSHA512:
return cryptoJS.SHA512(cryptoJS.enc.Hex.parse(msg)).toString();
case SignatureScheme.ECDSAwithSHA3_224:
return sha3_224(hexstring2ab(msg));
case SignatureScheme.ECDSAwithSHA3_256:
return sha3_256(hexstring2ab(msg));
case SignatureScheme.ECDSAwithSHA3_384:
return sha3_384(hexstring2ab(msg));
case SignatureScheme.ECDSAwithSHA3_512:
return sha3_512(hexstring2ab(msg));
case SignatureScheme.ECDSAwithRIPEMD160:
return cryptoJS.RIPEMD160(cryptoJS.enc.Hex.parse(msg)).toString();
case SignatureScheme.SM2withSM3:
return (new sm3()).sum(hexstring2ab(msg), 'hex');
default:
throw new Error('Unsupported hash algorithm.');
}
}
hash_sha3_384.hash = function (data) {
var hashBits = sjcl.codec.hex.toBits(sha3_384(bitsToBytes(data)));
return hashBits;
};