slicestring.go 723 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "strings"
  6. )
  7. //Compar - Comparison of two slices
  8. func Compar(small []string, big []string) (result bool) {
  9. var a int
  10. for i := 0; i < len(small); i++ {
  11. for _, b := range big {
  12. if b == small[i] {
  13. a++
  14. }
  15. }
  16. }
  17. if a != len(small) {
  18. return false
  19. }
  20. return true
  21. }
  22. //ToLow - Makes all cut letters small
  23. func ToLow(old []string) (new []string) {
  24. for _, a := range old {
  25. new = append(new, strings.ToLower(a))
  26. }
  27. return new
  28. }
  29. // RandString - There could be a regular hex :)
  30. func RandString(text string) string {
  31. a := md5.New()
  32. a.Write([]byte(strings.ToLower(text)))
  33. return hex.EncodeToString(a.Sum(nil))
  34. }