get New AES Key - Android java.security

Android examples for java.security:AES

Description

get New AES Key

Demo Code


//package com.java2s;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class Main {
    public static byte[] getNewAESKey() throws Exception {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(256); // for example
        SecretKey secretKey = keyGen.generateKey();
        return secretKey.getEncoded();
    }//from   w w  w  .ja v  a 2 s . com
}

Related Tutorials