Java Code Examples for org.jasypt.encryption.pbe.StandardPBEStringEncryptor#decrypt()
The following examples show how to use
org.jasypt.encryption.pbe.StandardPBEStringEncryptor#decrypt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tutorials File: JasyptUnitTest.java License: MIT License | 6 votes |
@Test @Ignore("should have installed local_policy.jar") public void givenTextPrivateData_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() { // given StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); String privateData = "secret-data"; encryptor.setPassword("some-random-data"); encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); // when String encryptedText = encryptor.encrypt("secret-pass"); assertNotSame(privateData, encryptedText); // then String plainText = encryptor.decrypt(encryptedText); assertEquals(plainText, privateData); }
Example 2
Source Project: hdw-dubbo File: BaseWebApplicationTests.java License: Apache License 2.0 | 5 votes |
/** * 解密 * @throws Exception */ @Test public void testDecrypt() throws Exception { StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor(); EnvironmentPBEConfig config = new EnvironmentPBEConfig(); //TODO: 加密的算法,这个算法是默认的 config.setAlgorithm("PBEWithMD5AndDES"); //TODO: 加密的密钥 config.setPassword(CommonConstant.JWT_DEFAULT_ISSUER); standardPBEStringEncryptor.setConfig(config); String encryptedText = "xRL1CVgzfFKBnPxCr+xjkg=="; String plainText = standardPBEStringEncryptor.decrypt(encryptedText); System.out.println(plainText); }
Example 3
Source Project: framework File: DataUtil.java License: Apache License 2.0 | 5 votes |
/** * Description: 解密 <br> * * @author 王伟<br> * @taskId <br> * @param password * @return <br> */ public static String decrypt(final 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); }
Example 4
Source Project: spring-boot-api-project-seed File: Jasypt.java License: Apache License 2.0 | 4 votes |
/** * 解密 * @param ciphertext 密文 * @return 明文 */ public static String decrypt(String ciphertext) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(KEY); return encryptor.decrypt(ciphertext); }
Example 5
Source Project: divide File: AuthTokenUtils.java License: Apache License 2.0 | 4 votes |
private static String decrypt(String string, String key){ StandardPBEStringEncryptor encryptor = getEncryptor(key); String decoded = Base64.decode(string); return encryptor.decrypt(decoded); }