Java Key Pair Create generateKey(String secretKey)

Here you can find the source of generateKey(String secretKey)

Description

generate Key

License

Apache License

Declaration

private static SecretKey generateKey(String secretKey) throws NoSuchAlgorithmException 

Method Source Code

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

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

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

public class Main {
    private static SecretKey generateKey(String secretKey) throws NoSuchAlgorithmException {
        SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
        secureRandom.setSeed(secretKey.getBytes());
        KeyGenerator kg = null;/* www.  j a  va  2s .  c o m*/
        try {
            kg = KeyGenerator.getInstance("DES");
        } catch (NoSuchAlgorithmException nosuchalgorithmexception) {
        }
        kg.init(secureRandom);
        return kg.generateKey();
    }
}

Related

  1. generateKey(String cipherAlgorithm)
  2. generateKey(String keyPhrase)
  3. generateKey(String password)
  4. generateKey(String PRIVATE_KEY_FILE, String PUBLIC_KEY_FILE)
  5. generateKey(String publicKeyFilename, String privateKeyFilename, String password)
  6. generateKey(String seed)
  7. generateKey(String type)
  8. generateKey(String userKey, String masterKey)
  9. generateKeyAES()