Created
July 8, 2013 00:37
-
-
Save kelvinewilliams/5945507 to your computer and use it in GitHub Desktop.
Simple way to salt passwords. For best results (and consistent sizes for database storage) hash the resulting string.
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
private static String saltIt(String passphrase) { | |
String saltChars = "i08q4h0fn23in2034qnvosysag01n40!$#@#$^@#$#ESDGASFXBSDFHDFH2"; | |
char[] salt = saltChars.toCharArray(); | |
StringBuilder stringBuilder = new StringBuilder(); | |
stringBuilder.append(passphrase); | |
for (char s : salt) { | |
stringBuilder.append(s); | |
stringBuilder.append(passphrase); | |
} | |
return stringBuilder.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Be sure to change the saltChars string before you re-use this code!