Add HTTP cAdvisor dependencies.

Also removed unused goamz.
This commit is contained in:
Victor Marmol
2015-03-11 10:29:10 -07:00
parent 6d465c4d86
commit e8d1359422
45 changed files with 5236 additions and 1057 deletions

View File

@@ -0,0 +1,30 @@
package auth
import "encoding/base64"
import "crypto/md5"
import "crypto/rand"
import "fmt"
/*
Return a random 16-byte base64 alphabet string
*/
func RandomKey() string {
k := make([]byte, 12)
for bytes := 0; bytes < len(k); {
n, err := rand.Read(k[bytes:])
if err != nil {
panic("rand.Read() failed")
}
bytes += n
}
return base64.StdEncoding.EncodeToString(k)
}
/*
H function for MD5 algorithm (returns a lower-case hex MD5 digest)
*/
func H(data string) string {
digest := md5.New()
digest.Write([]byte(data))
return fmt.Sprintf("%x", digest.Sum(nil))
}