Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(69)

Unified Diff: testservices/identityservice/util.go

Issue 6844087: goose: all current code
Patch Set: Created 12 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: testservices/identityservice/util.go
=== added file 'testservices/identityservice/util.go'
--- testservices/identityservice/util.go 1970-01-01 00:00:00 +0000
+++ testservices/identityservice/util.go 2012-11-11 15:29:52 +0000
@@ -0,0 +1,31 @@
+package identityservice
+
+import (
+ "crypto/rand"
+ "encoding/hex"
+ "fmt"
+)
+
+type UserInfo struct {
+ secret string
+ token string
+}
+
+// Generate a bit of random hex data for
+func randomHexToken() string {
+ raw_bytes := make([]byte, 16)
rog 2012/11/26 12:51:38 rawBytes or just "raw", or "buf"? the latter is p
+ n, err := rand.Read(raw_bytes)
rog 2012/11/26 12:51:38 io.ReadFull
+ if n != 16 || err != nil {
rog 2012/11/26 12:51:38 if err != nil {
+ panic(fmt.Sprintf(
+ "Could not read 16 random bytes safely: %d %s",
+ n, err.Error()))
+ }
rog 2012/11/26 12:51:38 return fmt.Sprintf("%x", ...)
+ hex_bytes := make([]byte, 32)
+ n = hex.Encode(hex_bytes, raw_bytes)
+ if n != 32 || err != nil {
+ panic(fmt.Sprintf(
+ "Failed to Encode 32 bytes: %d %s",
+ n, err.Error()))
+ }
+ return string(hex_bytes)
+}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b