going somewhere

This commit is contained in:
didier amyot committed 2014-11-09 18:28:08 -08:00
1 parent 6b3c99664c
commit 209af0d820
16 files changed
+549 -131

No files matched your search

+27
View File
@@ -1,6 +1,7 @@
package helper
import (
"crypto"
"errors"
"strings"
)
@@ -21,3 +22,29 @@ func JoinErrors(errs []error) error {
}
return JoinAsError(msgs)
}
func GetHashFunctionByLowerCaseName(hashName string) (crypto.Hash, error) {
switch hashName {
case "md4":
return crypto.MD4, nil
case "md5":
return crypto.MD5, nil
case "sha1":
return crypto.SHA1, nil
case "sha224":
return crypto.SHA224, nil
case "sha256":
return crypto.SHA256, nil
case "sha384":
return crypto.SHA384, nil
case "sha512":
return crypto.SHA512, nil
case "md5sha1":
return crypto.MD5SHA1, nil
case "ripemd160":
return crypto.RIPEMD160, nil
default:
return 0, errors.New("unknown lowercase hash " + hashName)
}
}