Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "crypto/hmac"
  5. "crypto/md5"
  6. "crypto/sha256"
  7. "crypto/sha512"
  8. "encoding/base64"
  9. "fmt"
  10. "io"
  11. )
  12.  
  13. func main() {
  14. input := "Lorem Ipsum dolor sit Amet"
  15. md5 := md5.New()
  16. sha_256 := sha256.New()
  17. sha_512 := sha512.New()
  18. io.WriteString(md5, input)
  19. sha_256.Write([]byte(input))
  20. sha_512.Write([]byte(input))
  21. sha_512_256 := sha512.Sum512_256([]byte(input))
  22. hmac512 := hmac.New(sha512.New, []byte("secret"))
  23. hmac512.Write([]byte(input))
  24.  
  25. //4db45e622c0ae3157bdcb53e436c96c5
  26. fmt.Printf("md5:\t\t%x\n", md5.Sum(nil))
  27.  
  28. //eb7a03c377c28da97ae97884582e6bd07fa44724af99798b42593355e39f82cb
  29. fmt.Printf("sha256:\t\t%x\n", sha_256.Sum(nil))
  30.  
  31. //5cdaf0d2f162f55ccc04a8639ee490c94f2faeab3ba57d3c50d41930a67b5fa6915a73d6c78048729772390136efed25b11858e7fc0eed1aa7a464163bd44b1c
  32. fmt.Printf("sha512:\t\t%x\n", sha_512.Sum(nil))
  33.  
  34. //34c614af69a2550a4d39138c3756e2cc50b4e5495af3657e5b726c2ac12d5e60
  35. fmt.Printf("sha512_256:\t%x\n", sha_512_256)
  36.  
  37. //GBZ7aqtVzXGdRfdXLHkb0ySp/f+vV9Zo099N+aSv+tTagUWuHrPeECDfUyd5WCoHBe7xkw2EdpyLWx+Ge4JQKg==
  38. fmt.Printf("hmac512:\t%s\n", base64.StdEncoding.EncodeToString(hmac512.Sum(nil)))
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement