The list of methods to do Key Create are organized into topic(s).
PrivateKey
getKey() get Key
KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(KEY);
return keyFactory.generatePrivate(privateKeySpec);
SecretKey
getKey() Gets the key.
KeySpec keySpec = new PBEKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
return keyFactory.generateSecret(keySpec);
Key
getKey() get Key
try {
InputStream fis = ClassLoader.getSystemResourceAsStream("key.pk8");
if (fis == null) {
throw new RuntimeException("Cannot find keyfile");
try {
return KeyFactory.getInstance("RSA")
.generatePrivate(new PKCS8EncodedKeySpec(getByteArrayFromStream(fis)));
...
Key
getKey(byte[] arrayBytesTemp) get Key
byte[] bytesTemp = new byte[8];
int len = arrayBytesTemp.length < bytesTemp.length ? arrayBytesTemp.length : bytesTemp.length;
for (int i = 0; i < len; i++) {
bytesTemp[i] = arrayBytesTemp[i];
Key key = new SecretKeySpec(bytesTemp, DEFAULT_ALGORITHM_NAME);
return key;
Key
getKey(InputStream is) get Key
try {
ObjectInputStream ois = new ObjectInputStream(is);
return (Key) ois.readObject();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
byte[]
getKey(int size) Generate a random key.
if (size < 1)
return null;
byte[] k = new byte[size];
_rand.nextBytes(k);
return k;
PrivateKey
getKey(KeyStore keyStore, String password, String orgName) Loads a private key with the specified org name from a keystore.
try {
PrivateKey key = (PrivateKey) keyStore.getKey(orgName, password.toCharArray());
if (key == null) {
throw new RuntimeException("Unable to get key for " + "name \"" + orgName + "\" using password \""
+ password + "\" from keystore");
return key;
} catch (Exception e) {
...