Worked on login remember cookie, and redirect after login

This commit is contained in:
Torkel Ödegaard
2015-01-27 12:05:23 +01:00
parent 6e5ef561eb
commit 257519490a
9 changed files with 98 additions and 5 deletions
+9
View File
@@ -2,8 +2,10 @@ package util
import (
"crypto/hmac"
"crypto/md5"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"hash"
)
@@ -28,6 +30,13 @@ func EncodePassword(password string, salt string) string {
return fmt.Sprintf("%x", newPasswd)
}
// Encode string to md5 hex value.
func EncodeMd5(str string) string {
m := md5.New()
m.Write([]byte(str))
return hex.EncodeToString(m.Sum(nil))
}
// http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto
func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte {
prf := hmac.New(h, password)