Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteSlice ¶ added in v0.2.2
ByteSlice produces a slice of random bytes, of a provided length also used as the base for other outputs returns nil if it fails to make the []byte, or if the created slice is the wrong size
Example ¶
// create a secure slice of bytes for use as a cryto key in a hash keylen := 64 //bytes pw := []byte("plain text password") // ByteSlice requires uint value for length key := ByteSlice(uint(keylen)) // Use the created key to hash the plain text password hmac := hmac.New(sha512.New, key) hmac.Write(pw) hashedPW := hmac.Sum(nil) // Clear the plain text password pw = nil // Use the key and hashedPW log.Printf("Password: \n%v\nSecure Key: \n%v\nHashed Password:\n%v", pw, key, hashedPW)
Output:
func String ¶
String returns a secure URL compliant string of a provided length returns a zero value string if it fails to create the message
Example ¶
// create a secure base64 encoded string for use as a unique identifer for a user type user struct { id string name string email string } // The size of our identifier var idLen uint = 128 //characters // String requires uint value for length key := String(idLen) // We now have a 128 character URL safe string to add to our user u := user{ id: key, name: "Testy McTestface", email: "testy@mctestface.com", } // Use the new user fmt.Printf("User ID: \n%v\nName: \n%v\nEmail:\n%v", u.id, u.name, u.email)
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.