Advertisement
defenceindepth

Bcrypt test

Jun 16th, 2012
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. public class Test
  2. {
  3.        static final long startTime = System.nanoTime();
  4.  
  5.  
  6.        public static void main(String[] args)
  7.        {
  8.  
  9.  
  10.                for (int i =12; i < 35; i++)
  11.                                {
  12.                                        final long endTime;
  13.  
  14.                                        String hashed = BCrypt.hashpw(args[0], BCrypt.gensalt(i));
  15.  
  16.                                        try
  17.                                        {
  18.                                                        compare(args[1],hashed);
  19.                                        }
  20.                                        finally
  21.                                        {
  22.                                                        endTime = System.nanoTime();
  23.                                        }
  24.  
  25.                                        final long duration = endTime - startTime;
  26.                                        double time = (double)duration/1000000000.0;
  27.  
  28.  
  29.                                        System.out.println(time +" seconds. | cost="+i);
  30.                                }
  31.        }
  32.  
  33.  
  34.        public static void compare(String compare, String hashed)
  35.        {
  36.                BCrypt.checkpw(compare, hashed);
  37.        }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement