decrypt AES/ECB/PKCS5Padding - Android java.security

Android examples for java.security:AES

Description

decrypt AES/ECB/PKCS5Padding

Demo Code


import android.annotation.SuppressLint;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Main{
    //from   w ww  .  ja v  a2  s  . com
    private static String decrypt(String input, int index) {
        byte[] output = null;
        try {
            SecretKeySpec skey = new SecretKeySpec(
                    DynamicEncryptUtil.findkeyBySortNum(index), "AES");
            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
            cipher.init(Cipher.DECRYPT_MODE, skey);
            output = cipher.doFinal(Base64.decode(input));
            //         output = CryptionUtil.decrypt(Base64.decode(input), index, PayApp.pay);
            return new String(output, "UTF-8");
        } catch (Exception e) {

        }
        return "";
    }
}

Related Tutorials