List of usage examples for java.security NoSuchAlgorithmException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.clustercontrol.accesscontrol.factory.LoginUserSelector.java
private static String hash(String password) { MessageDigest md = null;//from w w w. j a va 2 s .co m try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { m_log.info("hash() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); return null; } return Base64.encodeBase64String(md.digest(password.getBytes())); }
From source file:com.feilong.tools.security.symmetric.SymmetricEncryption.java
/** * (?).//from w ww . ja v a 2s . c o m * * @param symmetricType * the symmetric type * @param keyString * the key string * @param cipherMode * the cipher mode * @param cipherPadding * the cipher padding * @throws NullPointerException * if isNullOrEmpty(symmetricType) or isNullOrEmpty(keyString) * @throws EncryptionException * ?,EncryptionException? * @see SymmetricType * @see javax.crypto.Cipher#tokenizeTransformation(String) * @since 1.0.7 */ public SymmetricEncryption(SymmetricType symmetricType, String keyString, CipherMode cipherMode, CipherPadding cipherPadding) throws NullPointerException, EncryptionException { if (Validator.isNullOrEmpty(keyString)) { throw new NullPointerException("the keyString can't be null"); } if (Validator.isNullOrEmpty(symmetricType)) { throw new NullPointerException("the symmetricType can't be null"); } this.keyString = keyString; this.algorithm = symmetricType.getAlgorithm(); if (null == cipherMode && null == cipherPadding) { this.transformation = algorithm; } else { this.transformation = algorithm; if (null != cipherMode) { transformation += "/" + cipherMode; } if (null != cipherPadding) { transformation += "/" + cipherPadding; } } if (log.isDebugEnabled()) { log.debug("algorithm:[{}],keyString:[{}],transformation:[{}]", algorithm, keyString, transformation); } //,??,???? NoSuchAlgorithmException try { this.key = getKey(keyString); } catch (NoSuchAlgorithmException e) { log.error(e.getClass().getName(), e); throw new EncryptionException(e); } }