Documentation ¶
Overview ¶
Package sixty/crypto consolidates crypto funcionality used by the application
Index ¶
- func CreateEncodedCookie(rw http.ResponseWriter, name string, value string, expires int, httpOnly bool)
- func DecodedCookieValue(rw http.ResponseWriter, req *http.Request, name string) ([]byte, error)
- func DecryptEmailAddr(encEm string) (emAddr string, err error)
- func DeleteCookie(rw http.ResponseWriter, name string)
- func EncryptEmailAddr(em []byte) (hexEm string, err error)
- func EncryptPassword(rawPwd string, salt string) string
- func GetRandomString(n int) string
- func NewV4UUID() string
- type UUIDArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEncodedCookie ¶
func CreateEncodedCookie(rw http.ResponseWriter, name string, value string, expires int, httpOnly bool)
CreateEncodedCookie defines a cookie to be created by ResponseWriter The resulting cookie persists until manually deleted or until "expire" HOURS have passed. "Value" is hex encoded to comply with RFC6265
func DecodedCookieValue ¶
DecodedCookieValue returns the decoded Value of named cookie if it exists and can be decoded. Returns nil, nil if named cookie doesn't exist. Returns nil, err if there is a decoding error.
func DecryptEmailAddr ¶
DecryptEmailAddr takes an encrypted email addr as a string and returns a decrypted email address. If decryption fails, returns "" and a new error
func DeleteCookie ¶
func DeleteCookie(rw http.ResponseWriter, name string)
DeleteCookie marks named cookie for deletion by setting "Expires" to Unix epoch plus 1 second. Also sets MaxAge to -1 for modern browsers.
func EncryptEmailAddr ¶
EncryptEmailAddr takes an email address as a []byte and returns a hex encoded encrypted string suitable for storage in the user DB table. If encryption fails, returns "" and a new error
func EncryptPassword ¶
EncryptPassword uses pbkdf2 to encrypt password
func GetRandomString ¶
GenerateRandomString generates a random alphanumeric string