Example #1
0
func main() {
	for _, h := range []hash.Hash{md4.New(), md5.New(), sha1.New(),
		sha256.New224(), sha256.New(), sha512.New384(), sha512.New(),
		ripemd160.New()} {
		fmt.Printf("%x\n\n", h.Sum())
	}
}
Example #2
0
  Copyright (c) 2010, Abneptis LLC.
  See COPYRIGHT and LICENSE for details.
*/

import "crypto/hmac"
import "crypto/md4"
import "crypto/md5"
import "crypto/sha1"
import "crypto/sha256"
import "crypto/sha512"

import "hash"
import "strings"
import "os"

var Md4 = func() hash.Hash { return md4.New() }
var Md5 = func() hash.Hash { return md5.New() }
var Sha1 = func() hash.Hash { return sha1.New() }
var Sha256 = func() hash.Hash { return sha256.New() }
var Sha384 = func() hash.Hash { return sha512.New384() }
var Sha512 = func() hash.Hash { return sha512.New() }
var ErrUnknownHash = os.NewError("Unknown Hash")

/* Return a hash creation function based on a string;
   This function is case-insensitive, and currently accepts
   MD(4|5) and SHA(1|256|384|512)

   - If someone can confirm SHA==SHA1, I'll accept that as a
     name as well.
*/
func GetHashFunc(n string) (hf func() hash.Hash, err os.Error) {