sha1을 계산하려고하는데 sha1이 openssl 명령과 일치하지 않습니다.crypto/sha1이 openssl 명령과 일치하지 않습니다.
나는 나의 맥북에 같은 빈 파일의 해시를 계산 : 당신은 참조로 여기
package main
import "fmt"
import "crypto/sha1"
func main() {
hash := sha1.New()
hash.Write([]byte{0x00})
fmt.Printf("Hash got %x, expected da39a3ee5e6b4b0d3255bfef95601890afd80709", hash.Sum(nil))
}
이 출력됩니다 :
$ touch test.txt
$ openssl sha1 -hex test.txt
SHA1(test.txt)= da39a3ee5e6b4b0d3255bfef95601890afd80709
그리고 here 내가 가지고있는 간단한 테스트 코드 출력이 일치하지 않는 경우 누구나 내가 뭘 잘못하고 있는지 알 수 있습니까?
Hash got 5ba93c9db0cff93f52b521d7420e43f6eda2784f, expected da39a3ee5e6b4b0d3255bfef95601890afd80709
당신이 먹이 않는'test.txt' 콘텐츠를 sha1로 보내시겠습니까? 0 바이트의 sha1을 계산하지 않습니까? –
죄송합니다 - test.txt가 비어 있다고하셨습니다. 그러나 비어있는 것은 아마도 싱글 바이트 0 콘텐츠와 다릅니다. –