RandomUtil.go 408 B

1234567891011121314151617181920
  1. package util
  2. import (
  3. "demo/share"
  4. "fmt"
  5. "math/big"
  6. )
  7. const data = "66"
  8. var charArrays = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  9. func RandomArrays(charCount, hex int) string {
  10. result := ""
  11. for i := 0; i < charCount; i++ {
  12. randomInt := share.RandomInt(big.NewInt(0), big.NewInt(int64(hex))).Int64()
  13. result += fmt.Sprint(string(charArrays[randomInt]))
  14. }
  15. return result
  16. }