/** * DES algorithm */ private PBEStringEncryptor newEncryptor(final String passphrase) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(passphrase); return encryptor; } }
/* * First, create (or ask some other component for) the adequate encryptor for * decrypting the values in our .properties file. */ StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword("jasypt"); // could be got from web, env variable... /* * Create our EncryptableProperties object and load it the usual way. */ Properties props = new EncryptableProperties(encryptor); props.load(new FileInputStream("/path/to/my/configuration.properties")); /* * To get a non-encrypted value, we just get it with getProperty... */ String datasourceUsername = props.getProperty("datasource.username"); /* * ...and to get an encrypted value, we do exactly the same. Decryption will * be transparently performed behind the scenes. */ String datasourcePassword = props.getProperty("datasource.password"); // From now on, datasourcePassword equals "reports_passwd"...
/** * AES algorithm */ private PBEStringEncryptor newEncryptor(final String passphrase) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(passphrase); encryptor.setProvider(PROVIDER); encryptor.setAlgorithm(CRYPTO_ALGO); return encryptor; } }
private static void initialize(String key) { StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor(); standardPBEStringEncryptor.setAlgorithm("PBEWITHSHA1ANDDESEDE"); standardPBEStringEncryptor.setPassword(key); encryptor = standardPBEStringEncryptor; }
private static void initialize() { final Properties dbProps = DbProperties.getDbProperties(); if (EncryptionSecretKeyChecker.useEncryption()) { String dbSecretKey = dbProps.getProperty("db.cloud.encrypt.secret"); if (dbSecretKey == null || dbSecretKey.isEmpty()) { throw new CloudRuntimeException("Empty DB secret key in db.properties"); } s_encryptor = new StandardPBEStringEncryptor(); s_encryptor.setAlgorithm("PBEWithMD5AndDES"); s_encryptor.setPassword(dbSecretKey); } else { throw new CloudRuntimeException("Trying to encrypt db values when encrytion is not enabled"); } } }
/** * Sets a password. * * @param password the password to be set. */ public void setPassword(final String password) { this.encryptor.setPassword(password); }
/** * Sets a password. * * @param password the password to be set. */ public void setPassword(final String password) { this.encryptor.setPassword(password); }
/** * Sets a password. * * @param password the password to be set. */ public void setPassword(final String password) { this.encryptor.setPassword(password); }
/** * Sets a password. * * @param password the password to be set. */ public void setPassword(final String password) { this.encryptor.setPassword(password); }
/** * Sets a password. * * @param password the password to be set. */ public void setPassword(final String password) { this.encryptor.setPassword(password); }
public static void main(String[] args) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword("mySecretPassword"); String encryptedText = encryptor.encrypt("Hello World"); System.out.println("Encrypted text is: " + encryptedText); StandardPBEStringEncryptor decryptor = new StandardPBEStringEncryptor(); decryptor.setPassword("mySecretPassword"); String decryptedText = decryptor.decrypt(encryptedText); System.out.println("Decrypted text is: " + decryptedText); }
public JasyptPasswordEncryptor(String masterPassword, String algorithm) { passwordEncryptor = new StandardPBEStringEncryptor(); passwordEncryptor.setPassword(masterPassword); passwordEncryptor.setAlgorithm(algorithm); }
@Override protected void runTask(List<String> tokens) throws Exception { if( password == null ) { password = System.getenv("ACTIVEMQ_ENCRYPTION_PASSWORD"); } if (password == null || input == null) { context.printException(new IllegalArgumentException("input and password parameters are mandatory")); return; } encryptor.setPassword(password); context.print("Encrypted text: " + encryptor.encrypt(input)); }
@Override protected void runTask(List<String> tokens) throws Exception { if( password == null ) { password = System.getenv("ACTIVEMQ_ENCRYPTION_PASSWORD"); } if (password == null || input == null) { context.printException(new IllegalArgumentException("input and password parameters are mandatory")); return; } encryptor.setPassword(password); context.print("Encrypted text: " + encryptor.encrypt(input)); }
StandardPBEStringEncryptor encryptor =new StandardPBEStringEncryptor(); encryptor.setPassword("somePass"); encryptor.setAlgorithm("PBEWITHMD5ANDDES"); Configuration configuration = new Configuration().configure(); String pass=encryptor.decrypt(configuration.getProperty("hibernate.connection.password")); configuration.setProperty("hibernate.connection.password",pass);
/** * 编码 默认算法为"PBEWithMD5AndDES" * @param keyt 秘钥 * @param source 原始数据 * @return 这里每次加密后的密文结果都不一样 */ public static String encrypt(String keyt, String source){ StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(keyt); encryptor.setAlgorithm("PBEWithMD5AndDES"); return encryptor.encrypt(source); }
/** * * @param encryptor initialized encryptor * @param data * @return */ public static String decrypt(String encryptionAlgorithm, String encryptionKey, String data) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(encryptionKey); encryptor.setAlgorithm(encryptionAlgorithm); return decrypt(encryptor,data); }
private static String decryptPassword(String encryptedPassword, String encryptionKey) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(encryptionKey); encryptor.setAlgorithm("PBEWithMD5AndDES"); return PropertyValueEncryptionUtils.decrypt(encryptedPassword, encryptor); }
private StandardPBEStringEncryptor setupEncryptor(String password, String algorithm) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(password); encryptor.setAlgorithm(algorithm); return encryptor; } }
@Override public StringEncryptor getEncryptor() { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(getPassword()); encryptor.setSaltGenerator(new StringFixedSaltGenerator(getSalt())); return encryptor; }