Here you can find the source of decrypt(String encryptedText, String password)
public static String decrypt(String encryptedText, String password)
//package com.java2s; /**//from w w w . j av a 2 s . c om * Copyright 2013 Ralph Schaer <ralphschaer@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; import javax.xml.bind.DatatypeConverter; public class Main { public static final String ENCODE = "ENC"; public static String decrypt(String encryptedText, String password) { try { SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); SecretKey key = keyFactory.generateSecret(new PBEKeySpec(password.toCharArray())); Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); String enc = encryptedText.substring(ENCODE.length() + 12); byte[] salt = DatatypeConverter .parseBase64Binary(encryptedText.substring(ENCODE.length(), ENCODE.length() + 12)); pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(salt, 20)); return new String(pbeCipher.doFinal(DatatypeConverter.parseBase64Binary(enc))); } catch (InvalidKeyException | NoSuchAlgorithmException | InvalidKeySpecException | NoSuchPaddingException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException e) { throw new RuntimeException(e); } } }