Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2015 23:35
What would you like to do?
package codify
import (
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