(length int)
| 172 | } |
| 173 | |
| 174 | func GenerateRandomKey(length int) (string, error) { |
| 175 | bytes := make([]byte, length*3/4) // 对于48位的输出,这里应该是36 |
| 176 | if _, err := crand.Read(bytes); err != nil { |
| 177 | return "", err |
| 178 | } |
| 179 | return base64.StdEncoding.EncodeToString(bytes), nil |
| 180 | } |
| 181 | |
| 182 | func GenerateKey() (string, error) { |
| 183 | //rand.Seed(time.Now().UnixNano()) |
no outgoing calls
no test coverage detected