(n int)
| 477 | } |
| 478 | |
| 479 | func randomHex(n int) string { |
| 480 | buf := make([]byte, n) |
| 481 | if _, err := rand.Read(buf); err != nil { |
| 482 | // crypto/rand 在正常系统上不可能失败;若失败则 panic 而非回退到可预测值 |
| 483 | panic(fmt.Sprintf("payment: crypto/rand.Read failed: %v", err)) |
| 484 | } |
| 485 | return fmt.Sprintf("%x", buf) |
| 486 | } |
no test coverage detected