diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e9fb1e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +jbcrypt.iml +target/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9c87a7b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Change Log + +## 0.4.1 "StringBuilder" + - Replaced StringBuffer with StringBuilder because it is more efficient. + Efficiency is important because of the "work" required by this algorithm. + - Added maven.compiler.source/target = 1.8 since that's the earliest still-maintained version of Java. + - Added Maven enforcer plugin to be sure we are building with the latest defaults for Maven. + Use the following to check plugin and dependency versions: + ```text +mvn -U clean versions:display-plugin-updates +mvn -U clean versions:display-dependency-updates +``` + - Upgraded Junit from 3.8.1 to 4.13.1 (the latest). + - Added Changelog file + - Added .gitignore to avoid checking in Intellij or Maven files. + +## 0.4(.0) jeremyh/jBCrypt taken from djmdjm/jBCrypt + +This is an alternative distribution of jBCrypt. It has been packaged to ease use in existing applications — especially those using Apache Maven. + +The code is unchanged from the original jBCrypt 0.4, however: + +The classes have been moved to a java package to avoid pollution of the global namespace. org.mindrot was chosen to reflect their original origin. +The JBCrypt class javadoc has been changed to version 0.4. The official package incorrectly contains 0.2 as the stated version. +A pom.xml file has been added for use with Maven \ No newline at end of file diff --git a/README.md b/README.md index dfa6428..0769528 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,13 @@ The code is unchanged from the original jBCrypt 0.4, however: Install it to your local Maven repository: - mvn clean javadoc:jar source:jar install + mvn clean source:jar install Use it in your project by adding the following to your project *pom.xml*: org.mindrot jbcrypt - 0.3 + 0.4.1 diff --git a/pom.xml b/pom.xml index fbf30f8..c7dd495 100644 --- a/pom.xml +++ b/pom.xml @@ -4,21 +4,48 @@ org.mindrot jbcrypt - 0.4 + 0.4.1 jar jbcrypt http://www.mindrot.org/projects/jBCrypt + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce-maven + + enforce + + + + + [3.6.0,) + + + + + + + + + UTF-8 + 1.8 + 1.8 junit junit - 3.8.1 + 4.13.1 test diff --git a/src/main/java/org/mindrot/BCrypt.java b/src/main/java/org/mindrot/BCrypt.java index 188193f..110748c 100644 --- a/src/main/java/org/mindrot/BCrypt.java +++ b/src/main/java/org/mindrot/BCrypt.java @@ -59,7 +59,7 @@ * 10, and the valid range is 4 to 30. * * @author Damien Miller - * @version 0.4 + * @version 0.4.1 */ public class BCrypt { // BCrypt parameters @@ -388,7 +388,7 @@ public class BCrypt { private static String encode_base64(byte d[], int len) throws IllegalArgumentException { int off = 0; - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); int c1, c2; if (len <= 0 || len > d.length) @@ -441,7 +441,7 @@ private static byte char64(char x) { */ private static byte[] decode_base64(String s, int maxolen) throws IllegalArgumentException { - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); int off = 0, slen = s.length(), olen = 0; byte ret[]; byte c1, c2, c3, c4, o; @@ -654,7 +654,7 @@ public static String hashpw(String password, String salt) { byte passwordb[], saltb[], hashed[]; char minor = (char)0; int rounds, off = 0; - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); if (salt.charAt(0) != '$' || salt.charAt(1) != '2') throw new IllegalArgumentException ("Invalid salt version"); @@ -712,7 +712,7 @@ public static String hashpw(String password, String salt) { * @return an encoded salt value */ public static String gensalt(int log_rounds, SecureRandom random) { - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); byte rnd[] = new byte[BCRYPT_SALT_LEN]; random.nextBytes(rnd);