private String migrateValue(String value) { if (value == null || value.isEmpty()) { return value; } String decryptVal = oldEncryptor.decrypt(value); return newEncryptor.encrypt(decryptVal); }
public static String encrypt(String plain) { if (!EncryptionSecretKeyChecker.useEncryption() || (plain == null) || plain.isEmpty()) { return plain; } if (s_encryptor == null) { initialize(); } String encryptedString = null; try { encryptedString = s_encryptor.encrypt(plain); } catch (EncryptionOperationNotPossibleException e) { s_logger.debug("Error while encrypting: " + plain); throw e; } return encryptedString; }
private boolean migrateProperties(File dbPropsFile, Properties dbProps, String newMSKey, String newDBKey) { System.out.println("Migrating db.properties.."); StandardPBEStringEncryptor msEncryptor = new StandardPBEStringEncryptor(); ; initEncryptor(msEncryptor, newMSKey); try { PropertiesConfiguration newDBProps = new PropertiesConfiguration(dbPropsFile); if (newDBKey != null && !newDBKey.isEmpty()) { newDBProps.setProperty("db.cloud.encrypt.secret", "ENC(" + msEncryptor.encrypt(newDBKey) + ")"); } String prop = dbProps.getProperty("db.cloud.password"); if (prop != null && !prop.isEmpty()) { newDBProps.setProperty("db.cloud.password", "ENC(" + msEncryptor.encrypt(prop) + ")"); } prop = dbProps.getProperty("db.usage.password"); if (prop != null && !prop.isEmpty()) { newDBProps.setProperty("db.usage.password", "ENC(" + msEncryptor.encrypt(prop) + ")"); } newDBProps.save(dbPropsFile.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); return false; } System.out.println("Migrating db.properties Done."); return true; }
/** * Encrypts a message. * * @param message the message to be encrypted. * @see StandardPBEStringEncryptor#encrypt(String) */ public String encrypt(final String message) { return this.encryptor.encrypt(message); }
/** * Encrypts a message. * * @param message the message to be encrypted. * @see StandardPBEStringEncryptor#encrypt(String) */ public String encrypt(final String message) { return this.encryptor.encrypt(message); }
/** * Encrypts a message. * * @param message the message to be encrypted. * @see StandardPBEStringEncryptor#encrypt(String) */ public String encrypt(final String message) { return this.encryptor.encrypt(message); }
/** * Encrypts a message. * * @param message the message to be encrypted. * @see StandardPBEStringEncryptor#encrypt(String) */ public String encrypt(final String message) { return this.encryptor.encrypt(message); }
/** * Encrypts a message. * * @param message the message to be encrypted. * @see StandardPBEStringEncryptor#encrypt(String) */ public String encrypt(final String message) { return this.encryptor.encrypt(message); }
/** * Encrypts a message. * * @param message the message to be encrypted. * @see StandardPBEStringEncryptor#encrypt(String) */ public String encrypt(final String message) { return this.encryptor.encrypt(message); }
/** * Encrypt value string (but don't log error, for use in shell). * * @param value the value * @return the string */ public String encryptValuePropagateExceptions(final String value) { initializeJasyptInstanceIfNecessary(); return ENCRYPTED_VALUE_PREFIX + this.jasyptInstance.encrypt(value); }
@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)); }
String seed = "ipNumber"; String myIpValue = "192.168.0.1"; StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(seed); String encrypted= encryptor.encrypt(myIpValue);
@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 public String encrypt(final String plainText) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(SECURE_STRING); encryptor.setAlgorithm(SECURE_ALGORITHM); String result = plainText; try { result = encryptor.encrypt(plainText); } catch (EncryptionOperationNotPossibleException e) { log.error("Unable to encrypt", e); } return result; }
public class EncryptionDecryptionUsingJASYPT { private static String mpCryptoPassword = "BornToFight"; public static void main(String[] args) { String value = "Original Text: Eclipse"; System.out.println("Original Value : "+value); StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(mpCryptoPassword); String encryptedPassword = encryptor.encrypt(value); System.out.println(encryptedPassword); StandardPBEStringEncryptor decryptor = new StandardPBEStringEncryptor(); decryptor.setPassword(mpCryptoPassword); System.out.println(decryptor.decrypt(encryptedPassword)); } }
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); }
StandardPBEStringEncryptor myFirstEncryptor = new StandardPBEStringEncryptor(); myFirstEncryptor.setProvider(new BouncyCastleProvider()); myFirstEncryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); myFirstEncryptor.setPassword(myPassword); String myFirstEncryptedText = myFirstEncryptor.encrypt(myText);
/** * 编码 默认算法为"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); }
private String encrypt(final String unencryptedValue, final String jasyptAlgorithm, final String jasyptPassword) { final StandardPBEStringEncryptor encryptor = setupEncryptor(jasyptPassword, jasyptAlgorithm); return encryptor.encrypt(unencryptedValue); }