Android Key Create generateKey(byte[] seed)

Here you can find the source of generateKey(byte[] seed)


generate Key


Open Source License


public static byte[] generateKey(byte[] seed) throws Exception 

Method Source Code

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


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

public class Main {
    private static final String CIPHER_ALGORITHM = "AES";
    private static final String RANDOM_GENERATOR_ALGORITHM = "SHA1PRNG";
    private static final int RANDOM_KEY_SIZE = 128;

    public static byte[] generateKey(byte[] seed) throws Exception {
        KeyGenerator keyGenerator = KeyGenerator
        SecureRandom secureRandom = SecureRandom
        secureRandom.setSeed(seed);/*w  w  w .j a  v  a2  s .  com*/
        keyGenerator.init(RANDOM_KEY_SIZE, secureRandom);
        SecretKey secretKey = keyGenerator.generateKey();
        return secretKey.getEncoded();


  1. generateKey(String key)
  2. generateKey(byte[] randomSeed)
  3. getRawKey(byte[] seed)
  4. getRawKey(byte[] seed)
  5. createRandomKey(int size)
  6. generateKey(char[] passphraseOrPin, byte[] salt)
  7. generateKey(char[] passphraseOrPin, byte[] salt)
  8. generateMacSecret()
  9. getKey(String keyRule)