Android AES Decrypt decryptedPassword(String key, String encryptedData)

Here you can find the source of decryptedPassword(String key, String encryptedData)

Description

decrypted Password

Declaration

public static String decryptedPassword(String key, String encryptedData) 

Method Source Code

//package com.java2s;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Main {
    private static final String ENCODING = "ISO-8859-1";

    public static String decryptedPassword(String key, String encryptedData) {
        String decryptedUserData = "";
        try {/*w  ww. j  a  va  2s . com*/
            // Create key and cipher
            Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
            Cipher cipher = Cipher.getInstance("AES");
            // decrypt the text
            cipher.init(Cipher.DECRYPT_MODE, aesKey);
            byte[] userData = cipher.doFinal(encryptedData
                    .getBytes(ENCODING));
            decryptedUserData = new String(userData);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return decryptedUserData;
    }
}

Related

  1. decrypt(Context context, String encrypted)
  2. decrypt(Context context, String encrypted)
  3. decode(String seed, String encrypted)
  4. decrypt(byte[] raw, byte[] encrypted)
  5. decryptedData(String userkey, String encryptedData)