fango
unread,Sep 13, 2010, 8:12:36 PM9/13/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
printable rings like base64 or URL, so try `encoding` package. If you
don't need determinism, easier to use `crypto/rand` than `rand` for
byte array. Here's a demo:
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
)
const STRLEN = 80
func main(){
b := make([]byte, STRLEN)
rand.Read(b)
en := base64.StdEncoding // or URLEncoding
d := make([]byte, en.EncodedLen(len(b)))
en.Encode(d, b)
fmt.Printf("src=%s\ndst=%s\n", b, d)
}