Exemple #1
0
  private static MessageDigest getInstance() {

    if (INSTANCE == null) {
      try {
        INSTANCE = MessageDigest.getInstance("MD5");
      } catch (final NoSuchAlgorithmException anE) {
        BasicLogger.error(anE.toString());
      }
    }

    return INSTANCE;
  }
Exemple #2
0
  /**
   * @param aPassword An unencrypted (plain text) password
   * @param aToBytesEncoding
   * @param aFromBytesEncoding
   * @return An encrypted password
   */
  public static String encrypt(
      final String aPassword, final String aToBytesEncoding, final String aFromBytesEncoding) {

    String retVal = null;
    final MessageDigest tmpDigest = Password.getInstance();

    if (aPassword != null) {

      try {

        final byte[] tmpBytes = tmpDigest.digest(aPassword.getBytes(aToBytesEncoding));

        retVal = new String(tmpBytes, aFromBytesEncoding).trim();

      } catch (final UnsupportedEncodingException anE) {
        BasicLogger.error(anE.toString());
      }
    }

    return retVal;
  }
 /* (non-Javadoc)
  * @see comanche.loggers.Logger#log(java.lang.String)
  */
 public void log(String msg) {
   super.log(header + msg);
 }