Remove redundant code and add examples
This commit is contained in:
@@ -8,22 +8,61 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
str := "His money is twice tainted:"
|
||||
|
||||
var sha1 openssl.SHA_CTX
|
||||
sha1.Init()
|
||||
sha1.UpdateString("His money is twice tainted:")
|
||||
sha1.UpdateString(" 'taint yours and 'taint mine.")
|
||||
sha1.UpdateString(str)
|
||||
|
||||
h := make([]byte, openssl.SHA_DIGEST_LENGTH)
|
||||
sha1.Final(unsafe.SliceData(h))
|
||||
fmt.Printf("%x\n", h)
|
||||
h1 := make([]byte, openssl.SHA_DIGEST_LENGTH)
|
||||
sha1.Final(unsafe.SliceData(h1))
|
||||
fmt.Printf("%x\n", h1)
|
||||
|
||||
h2 := make([]byte, openssl.SHA_DIGEST_LENGTH)
|
||||
openssl.SHA1String(str, unsafe.SliceData(h2))
|
||||
fmt.Printf("%x\n", h2)
|
||||
|
||||
var sha256 openssl.SHA256_CTX
|
||||
sha256.Init()
|
||||
sha256.UpdateString("His money is twice tainted:")
|
||||
sha256.UpdateString(" 'taint yours and 'taint mine.")
|
||||
sha256.UpdateString(str)
|
||||
h3 := make([]byte, openssl.SHA256_DIGEST_LENGTH)
|
||||
sha256.Final(unsafe.SliceData(h3))
|
||||
fmt.Printf("%x\n", h3)
|
||||
|
||||
hh := make([]byte, openssl.SHA256_DIGEST_LENGTH)
|
||||
sha256.Final(unsafe.SliceData(hh))
|
||||
fmt.Printf("%x\n", hh)
|
||||
h4 := make([]byte, openssl.SHA256_DIGEST_LENGTH)
|
||||
openssl.SHA256String(str, unsafe.SliceData(h4))
|
||||
fmt.Printf("%x\n", h4)
|
||||
|
||||
var sha512 openssl.SHA512_CTX
|
||||
sha512.Init()
|
||||
sha512.UpdateString("His money is twice tainted:")
|
||||
|
||||
h5 := make([]byte, openssl.SHA512_DIGEST_LENGTH)
|
||||
sha512.Final(unsafe.SliceData(h5))
|
||||
fmt.Printf("%x\n", h5)
|
||||
|
||||
h6 := make([]byte, openssl.SHA512_DIGEST_LENGTH)
|
||||
openssl.SHA512String(str, unsafe.SliceData(h6))
|
||||
fmt.Printf("%x\n", h6)
|
||||
|
||||
var sha224 openssl.SHA256_CTX
|
||||
sha224.Init224()
|
||||
sha224.Update224String(str)
|
||||
|
||||
h7 := make([]byte, openssl.SHA224_DIGEST_LENGTH)
|
||||
sha224.Final224(unsafe.SliceData(h7))
|
||||
fmt.Printf("%x\n", h7)
|
||||
h8 := make([]byte, openssl.SHA224_DIGEST_LENGTH)
|
||||
openssl.SHA224String(str, unsafe.SliceData(h8))
|
||||
fmt.Printf("%x\n", h8)
|
||||
|
||||
var sha384 openssl.SHA512_CTX
|
||||
sha384.Init384()
|
||||
sha384.Update384String(str)
|
||||
h9 := make([]byte, openssl.SHA384_DIGEST_LENGTH)
|
||||
sha384.Final384(unsafe.SliceData(h9))
|
||||
fmt.Printf("%x\n", h9)
|
||||
h10 := make([]byte, openssl.SHA384_DIGEST_LENGTH)
|
||||
openssl.SHA384String(str, unsafe.SliceData(h10))
|
||||
fmt.Printf("%x\n", h10)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user