Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public signedHashing(data: string, signerPrivateKey: string, networkType: NetworkType) {
const dataHash = sha3_512(data);
if (networkType === NetworkType.MAIN_NET || networkType === NetworkType.TEST_NET) {
throw Errors[Errors.NETWORK_TYPE_NOT_SUPPORTED];
} else {
const signer = Account.createFromPrivateKey(signerPrivateKey, networkType);
return this.checksum + signer.signData(dataHash);
}
}
}
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.');
}
}