SHA-2,名称来自于安全散列算法2(英语:Secure Hash Algorithm 2)的缩写,一种密码散列函数算法标准,由美国国家安全局研发,由美国国家标准与技术研究院(NIST)在2001年发布。属于SHA算法之一,是SHA-1的后继者。其下又可再分为六个不同的算法标准,包括了:SHA-224、SHA-256、SHA-384、SHA-512、SHA-512/224、SHA-512/256。

package main

import (
    "crypto/sha512"
    "fmt"
    "io"
)

func main() {
    fmt.Println("go crypto sha512_224 demo.")
    str1 := "https://const.net.cn"
    str2 := "/"
    w := sha512.New512_224()
    io.WriteString(w, str1)
    io.WriteString(w, str2)

    hashstr := fmt.Sprintf("sha512_224 = %x", w.Sum(nil))
    fmt.Println(hashstr)
}

输出:

go run .
go crypto sha512_224 demo.
sha512_224 = ac8ef7fa5a2383df65cc9820b8e2ce548b540ca7756a2ba7d09218c9
echo -n "https://const.net.cn/" | openssl dgst -sha512-224
(stdin)= ac8ef7fa5a2383df65cc9820b8e2ce548b540ca7756a2ba7d09218c9
本文链接地址:https://const.net.cn/53.html

标签: sha512

添加新评论