Пример #1
0
 public String encryptPassword(String password) {
   try {
     return Base64.encodeBase64String(hash(password));
   } catch (NoSuchAlgorithmException ex) {
     return Exceptions.chuck(ex);
   }
 }
Пример #2
0
 public boolean checkPassword(String unhashed, String hashed) {
   try {
     byte[] bytes = hash(unhashed);
     byte[] check = Base64.decodeBase64(hashed);
     return Arrays.equals(bytes, check);
   } catch (NoSuchAlgorithmException ex) {
     return Exceptions.chuck(ex);
   }
 }