This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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