List of usage examples for javax.crypto Cipher DECRYPT_MODE
int DECRYPT_MODE
To view the source code for javax.crypto Cipher DECRYPT_MODE.
Click Source Link
From source file:ec.edu.uce.medicina.seguimiento.util.EncryptionUtility.java
/** *Mtodo que permite la desencriptacin de la contrasea * @param encrypted//from w w w .ja v a 2 s . co m * @return * @throws Exception */ public static String decrypt(String encrypted) throws Exception { String key = "02AE31B79CCCB2A3"; //llave String iv = "0123456789ABCDEF"; Cipher cipher = Cipher.getInstance(cI); SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), alg); IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes()); byte[] enc = decodeBase64(encrypted); cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivParameterSpec); byte[] decrypted = cipher.doFinal(enc); return new String(decrypted); }
From source file:com._64bitlabs.util.Encryptors.java
/** * Given AES encryption algorithm, decrypts the string value. * @param encryptedData/*ww w .ja v a2 s. c o m*/ * @return decrypted String */ public static String decrypt(String encryptedData) { Key key = generateKey(); try { Cipher c = Cipher.getInstance(ALGORITHM); c.init(Cipher.DECRYPT_MODE, key); Base64 dec = new Base64(); byte[] decodedValue = dec.decode(encryptedData.getBytes()); byte[] decValue = c.doFinal(decodedValue); return new String(decValue); } catch (Exception e) { return null; } }
From source file:com.liferay.sync.engine.lan.util.LanTokenUtil.java
public static String decryptLanToken(String lanTokenKey, String encryptedToken) throws Exception { byte[] bytes = DigestUtils.sha1(lanTokenKey); bytes = Arrays.copyOf(bytes, 16); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(bytes, "AES")); return new String(cipher.doFinal(Base64.decodeBase64(encryptedToken)), Charset.forName("UTF-8")); }
From source file:com.basp.trabajo_al_minuto.model.business.BusinessSecurity.java
/** * Se encarga de desencriptar la contrasea ingresada por el usuario * *///from w w w . j a va 2s .c om public static String decrypt(String encryptValue) throws BusinessException { String secretKey = "e-business"; String base64EncryptedString = ""; try { byte[] message = Base64.decodeBase64(encryptValue.getBytes("utf-8")); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, "DESede"); Cipher decipher = Cipher.getInstance("DESede"); decipher.init(Cipher.DECRYPT_MODE, key); byte[] plainText = decipher.doFinal(message); base64EncryptedString = new String(plainText, "UTF-8"); } catch (Exception ex) { throw new BusinessException(ex); } return base64EncryptedString; }
From source file:info.bonjean.beluga.util.CryptoUtil.java
private static Cipher getCipher(String strKey, boolean encoder) { Cipher cipher = null;/*from w w w. j a va2 s.co m*/ if (encoder) cipher = encryptCiphers.get(strKey); else cipher = decryptCiphers.get(strKey); if (cipher != null) return cipher; try { SecretKeySpec key = new SecretKeySpec(strKey.getBytes(), "Blowfish"); cipher = Cipher.getInstance("Blowfish/ECB/NoPadding"); cipher.init(encoder ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, key); if (encoder) encryptCiphers.put(strKey, cipher); else decryptCiphers.put(strKey, cipher); } catch (Exception e) { log.error(e.getMessage(), e); } return cipher; }
From source file:com.lwr.software.reporter.utils.EncryptionUtil.java
public static String decrypt(String encrypted) { try {/*w w w .j a v a 2 s . c o m*/ IvParameterSpec iv = new IvParameterSpec( DashboardConstants.INIT_VECTOR.getBytes(DashboardConstants.ENCODING)); SecretKeySpec skeySpec = new SecretKeySpec( DashboardConstants.INIT_KEY.getBytes(DashboardConstants.ENCODING), DashboardConstants.ALGORITHM); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted)); return new String(original); } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:com.kylinolap.rest.security.PasswordPlaceholderConfigurer.java
public static String decrypt(String strToDecrypt) { try {//w ww . j ava 2s . c o m Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); final SecretKeySpec secretKey = new SecretKeySpec(key, "AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt))); return decryptedString; } catch (Exception e) { } return null; }
From source file:com.netsteadfast.greenstep.util.EncryptorUtils.java
public static String decrypt(String key1, String iv1, String encrypted) { try {/* www . ja v a2s. c o m*/ IvParameterSpec iv = new IvParameterSpec(iv1.getBytes(Constants.BASE_ENCODING)); SecretKeySpec skeySpec = new SecretKeySpec(key1.getBytes(Constants.BASE_ENCODING), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted)); return new String(original); } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:D_common.E_ncript.java
public static byte[] decrypt(byte[] data, String keyStr) { try {//from ww w.j a v a2 s . com Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); final SecretKeySpec secretKey = new SecretKeySpec(makeAESKey(keyStr), "AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); return cipher.doFinal(data); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.zf.decipher.DataEn.java
private static byte[] decrypt(byte[] data) throws Exception { if (null == secretKey) { throw new SecurityException("secretKey is null"); }/* w ww .j a va2 s.c om*/ Cipher cipher = Cipher.getInstance(secretKey.getAlgorithm()); cipher.init(Cipher.DECRYPT_MODE, secretKey); return cipher.doFinal(data); }