Java Key Pair Create generateKey(String password)

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

Description

generate Key

License

Open Source License

Declaration

private static byte[] generateKey(String password) throws Throwable 

Method Source Code


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

import java.security.spec.KeySpec;

import javax.crypto.SecretKeyFactory;

import javax.crypto.spec.PBEKeySpec;

public class Main {
    private final static byte[] salt = new byte[] { -30, -91, -71, 33, 41, 115, -89, 34, 115, 30, -42, -5, 18, -72,
            -106, -30 };/*from w w w  .  j  a v a  2s.  com*/

    private static byte[] generateKey(String password) throws Throwable {
        KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128); // AES-128
        SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        return f.generateSecret(spec).getEncoded();
    }
}

Related

  1. generateKey(String algom, int keylength)
  2. generateKey(String algorithm, int keySize)
  3. generateKey(String algorithm, int size)
  4. generateKey(String cipherAlgorithm)
  5. generateKey(String keyPhrase)
  6. generateKey(String PRIVATE_KEY_FILE, String PUBLIC_KEY_FILE)
  7. generateKey(String publicKeyFilename, String privateKeyFilename, String password)
  8. generateKey(String secretKey)
  9. generateKey(String seed)