【问题标题】:how to generate sha1 similar to git hash-object command [duplicate]如何生成类似于 git hash-object 命令的 sha1 [重复]
【发布时间】:2017-03-27 18:36:49
【问题描述】:

知道为什么 git hash-object 与 shasum 和 openssl 命令的结果不同吗?

➜ printf test | shasum
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3  -

➜  printf test | git hash-object --stdin
30d74d258442c7c65512eafab474568dd706c430

➜  echo -n "test" | shasum
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3  -

【问题讨论】:

标签: git sha


【解决方案1】:

Git 添加一个包含 typelength 内容的标头,然后生成哈希。这就是为什么你会变得与众不同。

Here 是更详细的描述。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-15
    • 2011-07-14
    • 1970-01-01
    • 2012-08-18
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多