/sigmah/src/test/java/org/sigmah/server/auth/BCryptTest.java

http://sigma-h.googlecode.com/ · Java · 36 lines · 22 code · 10 blank · 4 comment · 0 complexity · cb90b4f2508bdfeee078f7e824cce8ad MD5 · raw file

  1. /*
  2. * All Sigmah code is released under the GNU General Public License v3
  3. * See COPYRIGHT.txt and LICENSE.txt.
  4. */
  5. package org.sigmah.server.auth;
  6. import org.junit.Ignore;
  7. import org.junit.Test;
  8. import org.sigmah.server.auth.impl.BCrypt;
  9. import static org.junit.Assert.assertTrue;
  10. public class BCryptTest {
  11. @Test
  12. public void realityCheck() {
  13. String input = "Hello world";
  14. String hashed = BCrypt.hashpw(input, BCrypt.gensalt());
  15. assertTrue(BCrypt.checkpw(input, hashed));
  16. }
  17. @Test
  18. @Ignore("for generating sample dbunit files only")
  19. public void generateSamples() {
  20. printSample("monday");
  21. printSample("tuesday");
  22. }
  23. private void printSample(String password) {
  24. System.out.println(password + " = " + BCrypt.hashpw(password, BCrypt.gensalt()));
  25. }
  26. }