Skip to content

Instantly share code, notes, and snippets.

@torazuka
Created April 16, 2011 12:20
Show Gist options
  • Save torazuka/923081 to your computer and use it in GitHub Desktop.
Save torazuka/923081 to your computer and use it in GitHub Desktop.
gist: 923079のテスト。
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import org.junit.Test;
public class HashedPassTest {
@Test
public void testStringToDigest() {
HashedPass check = new HashedPass();
boolean result1 = false;
boolean result2 = true;
try {
BigInteger b1 = check.stringToDigest("HogeMogaFuga");
BigInteger b2 = check.stringToDigest("HogeMogaFuga");
BigInteger b3 = check.stringToDigest("HogeMogaPiyo");
result1 = b1.equals(b2);
result2 = b1.equals(b3);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
assertTrue("元の文字列と入力文字列のハッシュ値が一致。", result1);
assertFalse("不一致。", result2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment