Created
April 16, 2011 12:18
-
-
Save torazuka/923079 to your computer and use it in GitHub Desktop.
DBに保存したハッシュ値(パスワード)とユーザ入力文字列のハッシュ値を突き合わせる。
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.math.BigInteger; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
public class HashedPass { | |
protected BigInteger stringToDigest(String str) | |
throws NoSuchAlgorithmException { | |
MessageDigest md = MessageDigest.getInstance("SHA-256"); | |
byte[] bytes = str.getBytes(); | |
md.update(bytes); | |
return new BigInteger(md.digest()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment