Android AES Decrypt decryptNumberWithAES(String encrypted)

Here you can find the source of decryptNumberWithAES(String encrypted)

Description

decrypt Number With AES

License

Open Source License

Declaration

public static String decryptNumberWithAES(String encrypted)
            throws NoSuchAlgorithmException, NoSuchPaddingException,
            InvalidKeyException, IllegalBlockSizeException,
            BadPaddingException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import android.util.Base64;

public class Main {
    public static String decryptNumberWithAES(String encrypted)
            throws NoSuchAlgorithmException, NoSuchPaddingException,
            InvalidKeyException, IllegalBlockSizeException,
            BadPaddingException {
        byte[] encryptedBytes = Base64.decode(encrypted, Base64.DEFAULT);

        String keyString = "intrepidlearner1"; // The key is exactly 16 bytes long
        byte[] key = keyString.getBytes();

        Cipher c = Cipher.getInstance("AES");
        SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
        c.init(Cipher.DECRYPT_MODE, keySpec);

        byte[] decryptedData = c.doFinal(encryptedBytes);

        return new String(decryptedData);

    }/*  www.  java  2  s.  c o m*/
}

Related

  1. decryptBytes(String key, byte[] src)
  2. decryptBytes(String seed, byte[] encrypted)
  3. decryptBytes(byte[] data, byte[] key)
  4. decryptHex(String content, String key)
  5. decryptHex(String content, String username, String password)
  6. decryptUrlDecode(String dataPassword, String encrypted)
  7. aesDecode(String seed, String encrypted)
  8. decrypt(byte[] raw, byte[] encrypted)
  9. decrypt(Context context, String encrypted)