Solidity:从字符串中获取哈希值;

时间:2018-03-22 21:53:40

标签: ethereum solidity smartcontracts

是否有可能以某种方式从solidity数组类型获取uint256哈希,例如字符串或bytes32 []?

我想创建映射(uint256 =>地址),其中uint256是用户之前输入的某个字符串的哈希值。 感谢名单!

1 个答案:

答案 0 :(得分:4)

You can use keccak256() on any Solidity type (including strings and arrays) to generate a bytes32 hash. From there, you can either just use the bytes32 result as your key or cast it to a uint.

Solidity documentation on keccak