org.springframework.security.crypto.bcrypt.BCrypt.encode_base64()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中org.springframework.security.crypto.bcrypt.BCrypt.encode_base64()方法的一些代码示例,展示了BCrypt.encode_base64()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BCrypt.encode_base64()方法的具体详情如下:
包路径:org.springframework.security.crypto.bcrypt.BCrypt
类名称:BCrypt
方法名:encode_base64

BCrypt.encode_base64介绍

[英]Encode a byte array using bcrypt's slightly-modified base64 encoding scheme. Note that this is not compatible with the standard MIME-base64 encoding.
[中]使用bcrypt稍加修改的base64编码方案对字节数组进行编码。请注意,这与标准MIME-base64编码不兼容。

代码示例

代码示例来源:origin: spring-projects/spring-security

  1. rs.append(log_rounds);
  2. rs.append("$");
  3. encode_base64(rnd, rnd.length, rs);
  4. return rs.toString();

代码示例来源:origin: org.springframework.security/spring-security-core

  1. /**
  2. * Generate a salt for use with the BCrypt.hashpw() method
  3. * @param log_rounds the log2 of the number of rounds of hashing to apply - the work
  4. * factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.
  5. * @param random an instance of SecureRandom to use
  6. * @return an encoded salt value
  7. */
  8. public static String gensalt(int log_rounds, SecureRandom random) {
  9. if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) {
  10. throw new IllegalArgumentException("Bad number of rounds");
  11. }
  12. StringBuilder rs = new StringBuilder();
  13. byte rnd[] = new byte[BCRYPT_SALT_LEN];
  14. random.nextBytes(rnd);
  15. rs.append("$2a$");
  16. if (log_rounds < 10) {
  17. rs.append("0");
  18. }
  19. rs.append(log_rounds);
  20. rs.append("$");
  21. encode_base64(rnd, rnd.length, rs);
  22. return rs.toString();
  23. }

代码示例来源:origin: spring-projects/spring-security

  1. private static String encode_base64(byte d[], int len)
  2. throws IllegalArgumentException {
  3. StringBuilder rs = new StringBuilder();
  4. BCrypt.encode_base64(d, len, rs);
  5. return rs.toString();
  6. }

代码示例来源:origin: spring-projects/spring-security

  1. rs.append(rounds);
  2. rs.append("$");
  3. encode_base64(saltb, saltb.length, rs);
  4. encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs);
  5. return rs.toString();

代码示例来源:origin: spring-projects/spring-security

  1. @Test(expected = IllegalArgumentException.class)
  2. public void moreBytesThanInTheArrayCannotBeEncoded() {
  3. BCrypt.encode_base64(new byte[1], 2, new StringBuilder());
  4. }

代码示例来源:origin: spring-projects/spring-security

  1. @Test(expected = IllegalArgumentException.class)
  2. public void emptyByteArrayCannotBeEncoded() {
  3. BCrypt.encode_base64(new byte[0], 0, new StringBuilder());
  4. }

代码示例来源:origin: org.springframework.security/spring-security-core

  1. encode_base64(saltb, saltb.length, rs);
  2. encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs);
  3. return rs.toString();

代码示例来源:origin: org.springframework.security/spring-security-crypto

  1. /**
  2. * Generate a salt for use with the BCrypt.hashpw() method
  3. * @param log_rounds the log2 of the number of rounds of hashing to apply - the work
  4. * factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.
  5. * @param random an instance of SecureRandom to use
  6. * @return an encoded salt value
  7. */
  8. public static String gensalt(int log_rounds, SecureRandom random) {
  9. if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) {
  10. throw new IllegalArgumentException("Bad number of rounds");
  11. }
  12. StringBuilder rs = new StringBuilder();
  13. byte rnd[] = new byte[BCRYPT_SALT_LEN];
  14. random.nextBytes(rnd);
  15. rs.append("$2a$");
  16. if (log_rounds < 10) {
  17. rs.append("0");
  18. }
  19. rs.append(log_rounds);
  20. rs.append("$");
  21. encode_base64(rnd, rnd.length, rs);
  22. return rs.toString();
  23. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Generate a salt for use with the BCrypt.hashpw() method
  3. * @param log_rounds the log2 of the number of rounds of hashing to apply - the work
  4. * factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.
  5. * @param random an instance of SecureRandom to use
  6. * @return an encoded salt value
  7. */
  8. public static String gensalt(int log_rounds, SecureRandom random) {
  9. if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) {
  10. throw new IllegalArgumentException("Bad number of rounds");
  11. }
  12. StringBuilder rs = new StringBuilder();
  13. byte rnd[] = new byte[BCRYPT_SALT_LEN];
  14. random.nextBytes(rnd);
  15. rs.append("$2a$");
  16. if (log_rounds < 10) {
  17. rs.append("0");
  18. }
  19. rs.append(log_rounds);
  20. rs.append("$");
  21. encode_base64(rnd, rnd.length, rs);
  22. return rs.toString();
  23. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Generate a salt for use with the BCrypt.hashpw() method
  3. * @param log_rounds the log2 of the number of rounds of hashing to apply - the work
  4. * factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.
  5. * @param random an instance of SecureRandom to use
  6. * @return an encoded salt value
  7. */
  8. public static String gensalt(int log_rounds, SecureRandom random) {
  9. if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) {
  10. throw new IllegalArgumentException("Bad number of rounds");
  11. }
  12. StringBuilder rs = new StringBuilder();
  13. byte rnd[] = new byte[BCRYPT_SALT_LEN];
  14. random.nextBytes(rnd);
  15. rs.append("$2a$");
  16. if (log_rounds < 10) {
  17. rs.append("0");
  18. }
  19. rs.append(log_rounds);
  20. rs.append("$");
  21. encode_base64(rnd, rnd.length, rs);
  22. return rs.toString();
  23. }

代码示例来源:origin: org.springframework.security/org.springframework.security.core

  1. /**
  2. * Generate a salt for use with the BCrypt.hashpw() method
  3. * @param log_rounds the log2 of the number of rounds of
  4. * hashing to apply - the work factor therefore increases as
  5. * 2**log_rounds.
  6. * @param random an instance of SecureRandom to use
  7. * @return an encoded salt value
  8. */
  9. public static String gensalt(int log_rounds, SecureRandom random) {
  10. if (log_rounds < 4 || log_rounds > 31) {
  11. throw new IllegalArgumentException("Bad number of rounds");
  12. }
  13. StringBuilder rs = new StringBuilder();
  14. byte rnd[] = new byte[BCRYPT_SALT_LEN];
  15. random.nextBytes(rnd);
  16. rs.append("$2a$");
  17. if (log_rounds < 10) {
  18. rs.append("0");
  19. }
  20. rs.append(log_rounds);
  21. rs.append("$");
  22. encode_base64(rnd, rnd.length, rs);
  23. return rs.toString();
  24. }

代码示例来源:origin: org.springframework.security/spring-security-crypto

  1. encode_base64(saltb, saltb.length, rs);
  2. encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs);
  3. return rs.toString();

代码示例来源:origin: org.springframework.security/org.springframework.security.core

  1. encode_base64(saltb, saltb.length, rs);
  2. encode_base64(hashed,
  3. bf_crypt_ciphertext.length * 4 - 1, rs);
  4. return rs.toString();

代码示例来源:origin: apache/servicemix-bundles

  1. encode_base64(saltb, saltb.length, rs);
  2. encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs);
  3. return rs.toString();

代码示例来源:origin: apache/servicemix-bundles

  1. encode_base64(saltb, saltb.length, rs);
  2. encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs);
  3. return rs.toString();

相关文章