Created
April 16, 2011 12:20
-
-
Save torazuka/923081 to your computer and use it in GitHub Desktop.
gist: 923079のテスト。
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 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