Java Key Pair Create generateKey()

Here you can find the source of generateKey()

Description

generate Key

License

Apache License

Declaration

public static byte[] generateKey() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.security.NoSuchAlgorithmException;

import javax.crypto.KeyGenerator;

import javax.crypto.SecretKey;

public class Main {

    public static byte[] generateKey() {
        try {/*from  www.  j ava2s  .c o  m*/
            KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
            keyGenerator.init(128);
            SecretKey key = keyGenerator.generateKey();
            return key.getEncoded();
        } catch (NoSuchAlgorithmException e) {
        }
        return null;
    }
}

Related

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