Android: Szyfruj łańcuch za pomocą 256-bitowego szyfrowania AES za pomocą iv i tajnego klucza

SecureRandom random = new SecureRandom(); // quite heavy, look into a lighter method.

String stringToEncrypt = "mypassword";
byte[] realiv = new byte[16];
random.nextBytes(realiv);
Cipher ecipher = Cipher.getInstance("AES");

SecureRandom random = new SecureRandom(); // quite heavy, look into a lighter method.

byte[] realiv = new byte[16];
random.nextBytes(realiv);       

byte[] secret = "somelongsecretkey".getBytes();
SecretKeySpec secretKey = new SecretKeySpec(secret, "AES");
ecipher.init(Cipher.ENCRYPT_MODE, secretKey, random);
byte[] encryptedData = ecipher.doFinal();

aleinit() pobiera tylko 3 parametry. Potrzebuję sposobu na zrobienie czegoś takiego:

ecipher.init(Cipher.ENCRYPT_MODE, stringToEncrypt, secretKey, random);

questionAnswers(2)

yourAnswerToTheQuestion