web3中的SHA3
使用keccak-256哈希算法,来计算哈希值,注意这不是标准的SHA3-256函数。
具体的实现如下图所示,需要先转为字节数组
调用:
var hashOfHash = web3.sha3("0000000000000000000000000000000000000000000000000000000000000002", {
encoding: 'hex'});
console.log(hashOfHash);
openssl实现
版本:openssl1.1.1
转换为字节数组
void hex2bytearray(char s[], unsigned char bits[])
{
int n = 0;
for (int i = 0; s[i]; i += 2) {
if (s[i] >= 'a' && s[i] <= 'f'