Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 18, 2015 23:35
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 lettergram/07b4286f5a5fd70befde to your computer and use it in GitHub Desktop.
Save lettergram/07b4286f5a5fd70befde to your computer and use it in GitHub Desktop.
package codify
import (
"crypto/sha256"
"encoding/hex"
"math/rand"
)
type Salting_Struct struct {
Username string
Salt string
}
// Runs a SHA-2 function on the string
func SHA(str string) string {
bytes := []byte(str)
// Converts string to sha2
h := sha256.New() // new sha256 object
h.Write(bytes) // data is now converted to hex
code := h.Sum(nil) // code is now the hex sum
codestr := hex.EncodeToString(code) // converts hex to string
return codestr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment