All Downloads are FREE. Search and download functionalities are using the official Maven repository.

devutility.internal.security.AesUtils Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
package devutility.internal.security;

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

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

/**
 * 
 * AesUtils
 * 
 * @author: Aldwin Su
 * @version: 2019-08-07 15:16:23
 */
public class AesUtils {
	public SecretKey secretKey(String key, int keySize) throws NoSuchAlgorithmException {
		KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
		keyGenerator.init(keySize, new SecureRandom(key.getBytes()));
		return keyGenerator.generateKey();
	}

	public SecretKey secretKey(String key) throws NoSuchAlgorithmException {
		return secretKey(key, 128);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy