Removed dependency to Sun package
This commit is contained in:
parent
196846e8e4
commit
afc0c792d3
1 changed files with 0 additions and 6 deletions
|
|
@ -136,18 +136,12 @@ public class Encrypter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Encrypter(String stringKey, Digest digest, Algorithm crypto, int iteration, int keyBitSize) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException {
|
public Encrypter(String stringKey, Digest digest, Algorithm crypto, int iteration, int keyBitSize) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException {
|
||||||
// Install SunJCE provider
|
|
||||||
Provider sunJce = new com.sun.crypto.provider.SunJCE();
|
|
||||||
Security.addProvider(sunJce);
|
|
||||||
|
|
||||||
// Generate the secret key specs.
|
// Generate the secret key specs.
|
||||||
//String instance = "PBEWith"+ digest +"And"+ crypto;
|
|
||||||
String instance = "PBKDF2With"+ digest;
|
String instance = "PBKDF2With"+ digest;
|
||||||
SecretKeyFactory factory = SecretKeyFactory.getInstance(instance);
|
SecretKeyFactory factory = SecretKeyFactory.getInstance(instance);
|
||||||
KeySpec keySpec = new PBEKeySpec(stringKey.toCharArray(), salt, iteration, keyBitSize);
|
KeySpec keySpec = new PBEKeySpec(stringKey.toCharArray(), salt, iteration, keyBitSize);
|
||||||
SecretKey tmp = factory.generateSecret(keySpec);
|
SecretKey tmp = factory.generateSecret(keySpec);
|
||||||
key = new SecretKeySpec(tmp.getEncoded(), crypto.toString());
|
key = new SecretKeySpec(tmp.getEncoded(), crypto.toString());
|
||||||
//key = new SecretKeySpec(stringKey.getBytes(), crypto.toString());
|
|
||||||
|
|
||||||
encipher = Cipher.getInstance(key.getAlgorithm());
|
encipher = Cipher.getInstance(key.getAlgorithm());
|
||||||
decipher = Cipher.getInstance(key.getAlgorithm());
|
decipher = Cipher.getInstance(key.getAlgorithm());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue