Skip to content

Instantly share code, notes, and snippets.

@torazuka
Created April 16, 2011 12:18
Show Gist options
  • Save torazuka/923079 to your computer and use it in GitHub Desktop.
Save torazuka/923079 to your computer and use it in GitHub Desktop.
DBに保存したハッシュ値(パスワード)とユーザ入力文字列のハッシュ値を突き合わせる。
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