Skip to content

Instantly share code, notes, and snippets.

@miekg
Created June 11, 2012 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miekg/2909715 to your computer and use it in GitHub Desktop.
Save miekg/2909715 to your computer and use it in GitHub Desktop.
Simple hashing and salting algo in Go
package main
import (
"crypto/sha1"
"fmt"
"io"
)
const ITER = 100000
func main() {
pass := "ik ben een wachtwoord"
salt := "4389fhdjn"
hash := sha1.New()
var encr []byte
io.WriteString(hash, salt + pass)
for i := 0; i < ITER; i++ {
encr = hash.Sum(nil)
io.WriteString(hash, string(encr))
}
fmt.Printf("%d %X\n", ITER, encr)
}
@miekg
Copy link
Author

miekg commented Jun 11, 2012

btw, dit zijn ITER+1 iteraties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment