You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

code.go 557 B

1234567891011121314151617181920212223
  1. // Copyright © 2023 OpenIMSDK open source community. All rights reserved.
  2. // Licensed under the MIT License (the "License");
  3. // you may not use this file except in compliance with the License.
  4. package utils
  5. import (
  6. "math/rand"
  7. "time"
  8. )
  9. // Generate a random code with length 6
  10. func GenerateCode() string {
  11. dataset := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()"
  12. rand.Seed(time.Now().UnixNano())
  13. code := make([]byte, 6)
  14. for i := 0; i < 6; i++ {
  15. code[i] = dataset[rand.Intn(len(dataset))]
  16. }
  17. return string(code)
  18. }