private static void initialize(String key) { StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor(); standardPBEStringEncryptor.setAlgorithm("PBEWITHSHA1ANDDESEDE"); standardPBEStringEncryptor.setPassword(key); encryptor = standardPBEStringEncryptor; }
public String decode(String encPass) throws UnsupportedOperationException { if (stringEncrypter == null) { // not initialized getStringEncoder(); } return stringEncrypter.decrypt(removePrefix(encPass)); }
/** * 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; } }
/** * DES algorithm */ private PBEStringEncryptor newEncryptor(final String passphrase) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(passphrase); return encryptor; } }
public static StandardPBEStringEncryptor createEncryptor() { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm("PBEWithMD5AndDES"); config.setPasswordEnvName("ACTIVEMQ_ENCRYPTION_PASSWORD"); encryptor.setConfig(config); return encryptor; }
/** * 解码 默认算法为"PBEWithMD5AndDES" * @param keyt 秘钥 * @param source ji * @return */ public static String decrypt(String keyt, String source){ StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(keyt); encryptor.setPassword(keyt); encryptor.setAlgorithm("PBEWithMD5AndDES"); return encryptor.decrypt(source); }
/** * Creates a new instance of <tt>StrongTextEncryptor</tt>. */ public StrongTextEncryptor() { super(); this.encryptor = new StandardPBEStringEncryptor(); this.encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); }
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));
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); }
@Override protected PasswordEncoder createStringEncoder() { byte[] password = lookupPasswordFromKeyStore(); char[] chars = toChars(password); try { stringEncrypter = new StandardPBEStringEncryptor(); stringEncrypter.setPasswordCharArray(chars); if (getProviderName() != null && !getProviderName().isEmpty()) { stringEncrypter.setProviderName(getProviderName()); } stringEncrypter.setAlgorithm(getAlgorithm()); JasyptPBEPasswordEncoderWrapper encoder = new JasyptPBEPasswordEncoderWrapper(); encoder.setPbeStringEncryptor(stringEncrypter); return encoder; } finally { scramble(password); scramble(chars); } }
/** * Description: 可以解密的加密<br> * * @author 王伟<br> * @taskId <br> * @param algorithm * @param password * @return <br> */ public static String encrypt(String password) { // 加密工具 StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); // 加密配置 EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm(ALGORITHM); // 自己在用的时候更改此密码 config.setPassword(SITE_WIDE_SECRET); // 应用配置 encryptor.setConfig(config); // 加密 return encryptor.encrypt(password); }
@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.setConfig(pbeConfig); String encrypted = encryptor.encrypt("foo"); String decrypted = encryptor.decrypt(encrypted); Assert.assertEquals("foo", decrypted);
private void initEncryptor(StandardPBEStringEncryptor encryptor, String secretKey) { encryptor.setAlgorithm("PBEWithMD5AndDES"); SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig(); stringConfig.setPassword(secretKey); encryptor.setConfig(stringConfig); }
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(seed); String decrypted = encryptor.decrypt(encrypted);
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); try { context.print("Decrypted text: " + encryptor.decrypt(input)); } catch (EncryptionOperationNotPossibleException e) { context.print("ERROR: Text cannot be decrypted, check your input and password and try again!"); } }
/** * Description: 解密<br> * * @author 王伟<br> * @taskId <br> * @param algorithm * @param password * @return <br> */ public static String decrypt(String password) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); // 加密配置 EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm(ALGORITHM); // 自己在用的时候更改此密码 config.setPassword(SITE_WIDE_SECRET); // 应用配置 encryptor.setConfig(config); // 解密 return encryptor.decrypt(password); }
@Override public StringEncryptor getEncryptor() { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(getPassword()); encryptor.setSaltGenerator(new StringFixedSaltGenerator(getSalt())); return encryptor; }