Java Key Pair Create generateKey()

Here you can find the source of generateKey()

Description

Step 1.

License

Open Source License

Declaration

public static SecretKey generateKey() throws NoSuchAlgorithmException 

Method Source Code


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

import javax.crypto.*;

import java.security.NoSuchAlgorithmException;

public class Main {
    private static final int AES_KEYLENGTH = 128;

    /**//w  w w .j  a v  a2s  .  c om
     * Step 1. Generate an AES key using KeyGenerator Initialize the
     * keysize to 128 bits (16 bytes)
     */
    public static SecretKey generateKey() throws NoSuchAlgorithmException {
        KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
        keyGenerator.init(AES_KEYLENGTH);
        return keyGenerator.generateKey();
    }
}

Related

  1. generateKey()
  2. generateKey()
  3. generateKey()
  4. generateKey()
  5. generateKey()
  6. generateKey()
  7. generateKey()