PageRenderTime 109ms CodeModel.GetById 61ms app.highlight 1ms RepoModel.GetById 45ms app.codeStats 0ms

/game/util.go

http://golang-game-server.googlecode.com/
Go | 17 lines | 12 code | 3 blank | 2 comment | 0 complexity | ca9094810cda6bb933de76bce8434e83 MD5 | raw file
 1// Copyright (C) 2010 Alex Gontmakher (gsasha@gmail.com)
 2// This code is licensed under GPLv3
 3
 4package game
 5
 6import (
 7    "crypto/rand"
 8    "encoding/base64"
 9)
10
11func create_random_id(bytes int) string {
12    random_bytes := make([]byte, bytes)
13    random_id := make([]byte, base64.URLEncoding.EncodedLen(bytes))
14    rand.Read(random_bytes)
15    base64.URLEncoding.Encode(random_id, random_bytes)
16    return string(random_id)
17}