1
0
Fork 0
mirror of https://github.com/vbatts/dedupe-linker.git synced 2025-03-24 01:24:18 +00:00
dedupe-linker/cryptomap/crypto.go
Vincent Batts 7ea5cd6bc4 cryptomap: golint
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-13 10:40:39 -04:00

42 lines
801 B
Go

package cryptomap
import (
"crypto"
"log"
"strings"
// Importing all the currently supported hashes
_ "crypto/md5"
_ "crypto/sha1"
_ "crypto/sha256"
_ "crypto/sha512"
)
var knownCiphers = map[string]crypto.Hash{
"md5": crypto.MD5,
}
// DetermineHash takes a generic string, like "sha1" and returns the
// corresponding crypto.Hash
func DetermineHash(str string) (h crypto.Hash) {
// TODO make these strings discoverable, like a public variable
switch strings.ToLower(str) {
case "md5":
h = crypto.MD5
case "sha1":
h = crypto.SHA1
case "sha224":
h = crypto.SHA224
case "sha256":
h = crypto.SHA256
case "sha384":
h = crypto.SHA384
case "sha512":
h = crypto.SHA512
default:
log.Printf("WARNING: unknown cipher %q. using 'sha1'", str)
h = crypto.SHA1
}
return h
}