【问题标题】:Is substrate T::Hashing::hash_of(...) return a random hash?底物 T::Hashing::hash_of(...) 返回随机散列吗?
【发布时间】:2021-12-30 17:34:50
【问题描述】:

在基板中,我有一个获取哈希的代码:

            let kitty = Kitty::<T> {
                dna: String::from("test"),
                price: None,
                gender: String::from("male"),
                owner: "there's an accountid here",
            };

            let kitty_id = T::Hashing::hash_of(&kitty);

如果将相同的 kitty 属性传递给 hash_of 函数,我能否得到相同的 kitty_id 哈希?

【问题讨论】:

  • 您是在托盘中还是在哪里调用它?除非您知道自己在做什么,否则使用非随机输入调用散列函数通常是不安全的。
  • 是的,谢谢,我找到了答案,因为 kitty.dna 是从随机结果中获得的,所以这将是一个随机哈希。否则,这是可以预测的

标签: substrate


【解决方案1】:

不,这不会返回随机哈希。它返回输入数据的哈希值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-30
    • 2012-09-09
    • 2023-04-08
    • 1970-01-01
    • 2019-09-26
    • 2012-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多