Last active
August 29, 2015 13:57
-
-
Save saw303/9652514 to your computer and use it in GitHub Desktop.
A script to generate a valid SHA-512 HEX-ified hashes to reset a users password
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
import java.security.MessageDigest | |
import java.security.NoSuchAlgorithmException | |
import java.security.SecureRandom | |
def password = 'my pwd' | |
def username = 'a users name' | |
def passwordToHash = "${password}{${username}}" | |
MessageDigest md = MessageDigest.getInstance 'SHA-512' | |
byte[] bytes = md.digest passwordToHash.getBytes() | |
9999.times { | |
bytes = md.digest bytes | |
} | |
generatedPassword = bytes.encodeHex() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment