Java AES aesCrypt(byte[] content, Key key, int crypt)

Here you can find the source of aesCrypt(byte[] content, Key key, int crypt)

Description

aes Crypt

License

Open Source License

Declaration

private static byte[] aesCrypt(byte[] content, Key key, int crypt) 

Method Source Code


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

import javax.crypto.Cipher;

import java.security.Key;

public class Main {
    private static final String AES_CIPER_ALGRITHM = "AES/ECB/PKCS5Padding";

    private static byte[] aesCrypt(byte[] content, Key key, int crypt) {
        try {/*from  w  w  w . j av  a 2  s.  c om*/
            Cipher cipher = Cipher.getInstance(AES_CIPER_ALGRITHM);
            cipher.init(crypt, key);
            return cipher.doFinal(content);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return content;
    }
}

Related

  1. aesCipher()
  2. aesHandler(byte[] toBeHandleData, String password, boolean isEncrypt)
  3. aesKey(int keySize)
  4. aesStoreKeyToFile(Key secretKey, String path)
  5. createSessionKey()