library: crypto/rand
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := 10
|
||||
b := make([]byte, c)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
fmt.Println("error:", err)
|
||||
return
|
||||
}
|
||||
// The slice should now contain random bytes instead of only zeroes.
|
||||
fmt.Printf("%x\n", b)
|
||||
}
|
||||
Reference in New Issue
Block a user