Java AES createSessionKey()

Here you can find the source of createSessionKey()

Description

Creates random session keys

License

Open Source License

Exception

Parameter Description
Exception an exception

Declaration

public static String createSessionKey() throws Exception 

Method Source Code

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

import javax.crypto.KeyGenerator;

import javax.xml.bind.DatatypeConverter;

public class Main {
    /**/*from  w  w  w  .j  a va 2  s .com*/
     * Creates random session keys
     * @return
     * @throws Exception
     */
    public static String createSessionKey() throws Exception {
        KeyGenerator gen = KeyGenerator.getInstance("AES");
        gen.init(128);
        byte[] original = gen.generateKey().getEncoded();
        String s = DatatypeConverter.printBase64Binary(original);
        return s;
    }
}

Related

  1. aesCipher()
  2. aesCrypt(byte[] content, Key key, int crypt)
  3. aesHandler(byte[] toBeHandleData, String password, boolean isEncrypt)
  4. aesKey(int keySize)
  5. aesStoreKeyToFile(Key secretKey, String path)
  6. decrypt(String encryptedText, String key)
  7. decrypt_aes(String key, String initVector, String encrypted)
  8. encryptAes(String value)
  9. encryptDecrypt(int mode, String data, String key, String salt, String iv)