Package org.mindrot.jbcrypt

Examples of org.mindrot.jbcrypt.BCrypt


        rounds = determineBestRounds();
      }

      int plaintext[] = {0x155cbf8e, 0x57f57513, 0x3da787b9, 0x71679d82,
                         0x7cf72e93, 0x1ae25274, 0x64b54adc, 0x335cbd0b};
      BCrypt bcrypt = new BCrypt();
      byte[] rawBytes = bcrypt.crypt_raw(password.getBytes("UTF-8"),
                                         salt, rounds, plaintext);
      SecretKeySpec spec = new SecretKeySpec(rawBytes, KEY_FACTORY);
      info.encryptCipher = Cipher.getInstance(KEY_FACTORY);
      info.encryptCipher.init(Cipher.ENCRYPT_MODE, spec);
View Full Code Here


  public static int determineBestRounds() {
      byte[] salt = createNewSalt();
      int plaintext[] = {0x155cbf8e, 0x57f57513, 0x3da787b9, 0x71679d82,
                         0x7cf72e93, 0x1ae25274, 0x64b54adc, 0x335cbd0b};
      final byte[] password = {1, 2, 3, 4, 5, 6, 7, 8};
      BCrypt bcrypt = new BCrypt();

      // Calculate the time to create a cipher key with 4 rounds, in msecs.
      // Do it twice and take the average.
      final long start = System.currentTimeMillis();
      bcrypt.crypt_raw(password, salt, 4, plaintext);
      bcrypt.crypt_raw(password, salt, 4, plaintext);
      final long T4 = (System.currentTimeMillis() - start) / 2;

      // If T4 is the time in msecs to create the key with 4 rounds, then
      // the time Tn to calculate the key using n rounds (n > 4) is:
      //
View Full Code Here

TOP

Related Classes of org.mindrot.jbcrypt.BCrypt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.