/** * <p> * Set the number of hashing iterations applied to obtain the * encryption key. * </p> * <p> * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * @param keyObtentionIterations the number of iterations */ public void setKeyObtentionIterations(final int keyObtentionIterations) { this.firstEncryptor.setKeyObtentionIterations(keyObtentionIterations); }
/** * <p> * Set the number of hashing iterations applied to obtain the * encryption key. * </p> * <p> * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * @param keyObtentionIterations the number of iterations */ public void setKeyObtentionIterations(final int keyObtentionIterations) { this.firstEncryptor.setKeyObtentionIterations(keyObtentionIterations); }
/** * <p> * Set the number of hashing iterations applied to obtain the * encryption key. * </p> * <p> * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * @param keyObtentionIterations the number of iterations */ public void setKeyObtentionIterations(final int keyObtentionIterations) { this.firstEncryptor.setKeyObtentionIterations(keyObtentionIterations); }
/** * Sets key obtention iterations. * * @param iter the iter */ public void setKeyObtentionIterations(final String iter) { if (StringUtils.isNotBlank(iter) && NumberUtils.isCreatable(iter)) { LOGGER.debug("Configured Jasypt iterations"); jasyptInstance.setKeyObtentionIterations(Integer.parseInt(iter)); } }
/** * Sets the key obtention iterations to be used by the internal encryptor, * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>. * * @param keyObtentionIterations to be set for the internal encryptor */ public void setKeyObtentionIterations(final int keyObtentionIterations) { if (this.encryptorSet) { throw new EncryptionInitializationException( "An encryptor has been already set: no " + "further configuration possible on hibernate wrapper"); } final StandardPBEStringEncryptor standardPBEStringEncryptor = (StandardPBEStringEncryptor) this.encryptor; standardPBEStringEncryptor.setKeyObtentionIterations( keyObtentionIterations); }
StandardPBEStringEncryptor myFirstEncryptor = new StandardPBEStringEncryptor(); myFirstEncryptor.setProvider(new BouncyCastleProvider()); myFirstEncryptor.setAlgorithm("PBEWITHSHA256AND256BITAES-CBC-BC"); FixedStringSaltGenerator generator = new FixedStringSaltGenerator(); generator.setSalt("justAnotherSaltforGX"); //myFirstEncryptor.setSaltGenerator(new ZeroSaltGenerator()); myFirstEncryptor.setSaltGenerator(generator); myFirstEncryptor.setKeyObtentionIterations(1); String myPassword="creditCard"; myFirstEncryptor.setPassword(myPassword); String myText="Redeem Gacha "; String myFirstEncryptedText = myFirstEncryptor.encrypt(myText); System.out.println("myFirstEncryptedText AES encrypt=="+myFirstEncryptedText); System.out.println("myFirstEncryptedText AES decrypt =="+myFirstEncryptor.decrypt(myFirstEncryptedText));
encryptor.setAlgorithm("PBEWithMD5AndDES"); encryptor.setPassword("123456"); encryptor.setKeyObtentionIterations(1000); encryptor.initialize();
newEncryptor.setKeyObtentionIterations( this.keyObtentionIterations.intValue());