some_tool.go 422 B

12345678910111213141516171819202122232425
  1. package tool
  2. import (
  3. "crypto/sha256"
  4. "encoding/hex"
  5. "html/template"
  6. "net/url"
  7. )
  8. func Sha224(data string) string {
  9. hasher := sha256.New224()
  10. hasher.Write([]byte(data))
  11. hash_byte := hasher.Sum(nil)
  12. hash_str := hex.EncodeToString(hash_byte)
  13. return hash_str
  14. }
  15. func Url_parser(data string) string {
  16. return url.QueryEscape(data)
  17. }
  18. func HTML_escape(data string) string {
  19. return template.HTMLEscapeString(data)
  20. }