]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/PasswordHash.java
upd: transform existing mails into mail templates
[gigi.git] / src / org / cacert / gigi / util / PasswordHash.java
index ed0d4f3c251903a0400552e1db0f6b2a1e75b20e..6d598e77575f706fb8d6804eb9dcab748394b408 100644 (file)
@@ -15,7 +15,8 @@ public class PasswordHash {
      *            The password that should result in the given hash.
      * @param hash
      *            The hash to verify the password against.
-     * @return <ul>
+     * @return
+     *         <ul>
      *         <li><code>null</code>, if the password was valid</li>
      *         <li><code>hash</code>, if the password is valid and the hash
      *         doesn't need to be updated</li>
@@ -24,6 +25,9 @@ public class PasswordHash {
      *         </ul>
      */
     public static String verifyHash(String password, String hash) {
+        if (password == null || password.isEmpty()) {
+            return null;
+        }
         if (hash.contains("$")) {
             if (SCryptUtil.check(password, hash)) {
                 return hash;
@@ -46,7 +50,7 @@ public class PasswordHash {
         }
     }
 
-    private static String sha1(String password) {
+    public static String sha1(String password) {
         try {
             MessageDigest md = MessageDigest.getInstance("SHA1");
             byte[] digest = md.digest(password.getBytes("UTF-8"));