Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created July 10, 2016 09:01
Show Gist options
  • Save bgnori/553a4ad468243be1f4ef1193ca92f262 to your computer and use it in GitHub Desktop.
Save bgnori/553a4ad468243be1f4ef1193ca92f262 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
)
func main() {
b := make([]byte, 100)
n, err := rand.Reader.Read(b)
if err != nil {
panic(err)
}
fmt.Printf("read %d bytes\n", n)
encoded := base64.StdEncoding.EncodeToString(b)
fmt.Println(encoded)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment