本文整理汇总了Java中org.jasypt.util.text.BasicTextEncryptor.encrypt方法的典型用法代码示例。如果您正苦于以下问题:Java BasicTextEncryptor.encrypt方法的具体用法?Java BasicTextEncryptor.encrypt怎么用?Java BasicTextEncryptor.encrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jasypt.util.text.BasicTextEncryptor
的用法示例。
在下文中一共展示了BasicTextEncryptor.encrypt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static void main(String[] args) {
if (args != null && args.length == 2) {
if (args[0].equals("-encrypt")) {
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(secret);
String plainText = textEncryptor.encrypt(args[1]);
System.out.println("Encrypted Password is :" + plainText);
return;
}
} else if (args != null && args.length > 0) {
System.out.println(
"Usage: ./mmagent to run with the configuration \n -encrypt <password> to Encrypt Password for config ");
return;
}
MirrorMakerAgent agent = new MirrorMakerAgent();
if (agent.checkStartup()) {
logger.info("mmagent started, loading properties");
agent.checkAgentProcess();
agent.readAgentTopic();
} else {
System.out.println(
"ERROR: mmagent startup unsuccessful, please make sure the mmagenthome /etc/mmagent.config is set and mechid have the rights to the topic");
}
}
示例2: encryptProperty
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public void encryptProperty(String key)
{
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(ENC_PASSWORD);
final String decryptedValue = getProperty(key);
if (decryptedValue != null && !decryptedValue.isEmpty())
{
try
{
final String encryptedValue = textEncryptor.encrypt(decryptedValue);
setProperty(key, encryptedValue);
}
catch (Exception e)
{
final String errorMessage = "Error encrypting value for " + key + " property";
logger.error(errorMessage, e);
ChatWindow.popup.handleProblem(errorMessage);
setProperty(key, "");
}
}
}
示例3: encrypt
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static String encrypt(final String valueEnc) {
if (valueEnc == null) {
return null;
}
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(MY_ENCRIPTED_PASSWORD);
return textEncryptor.encrypt(valueEnc);
}
示例4: main
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
public static void main(String[] args) {
String password = args.length >= 1 ? args[0] : "strong";
String text = args.length >= 2 ? args[1] : "i am hero";
PasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(password);
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(encryptedPassword);
String myEncryptedText = textEncryptor.encrypt(text);
System.out.println(myEncryptedText);
}
示例5: testBasicEncryptionAndDecryption
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
@Test
public void testBasicEncryptionAndDecryption() throws IOException {
String password = UUID.randomUUID().toString();
String masterPassword = UUID.randomUUID().toString();
File masterPwdFile = getMasterPwdFile(masterPassword);
State state = new State();
state.setProp(ConfigurationKeys.ENCRYPT_KEY_LOC, masterPwdFile.toString());
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword(masterPassword);
String encrypted = encryptor.encrypt(password);
encrypted = "ENC(" + encrypted + ")";
String decrypted = PasswordManager.getInstance(state).readPassword(encrypted);
Assert.assertEquals(decrypted, password);
}
示例6: setEncryptedPassphrase
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
private void setEncryptedPassphrase(String plainPassphrase, State state) throws IOException {
String masterPassword = UUID.randomUUID().toString();
createMasterPwdFile(masterPassword);
state.setProp(ConfigurationKeys.ENCRYPT_KEY_LOC, this.masterPwdFile.toString());
state.setProp(ConfigurationKeys.ENCRYPT_USE_STRONG_ENCRYPTOR, false);
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword(masterPassword);
String encrypted = encryptor.encrypt(plainPassphrase);
state.setProp("converter.decrypt.passphrase", "ENC(" + encrypted + ")");
}
示例7: encryptMessage
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
/**
* Encrypt Message into a Base 64 String Data
*
* @param message to be encrypted
* @return String BASE64 encoded Encrypted String of Message.
*/
public static String encryptMessage(String message) {
initializeDefaultCryptographyProvider();
BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor();
basicTextEncryptor.setPassword(SALT_PW);
return basicTextEncryptor.encrypt(message);
}
示例8: basicTestEncryptor
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
@Test
public void basicTestEncryptor() {
for (String algorithm : EncryptorAlgorithms) {
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword("debop");
String encrypted = encryptor.encrypt(PLAIN_TEXT);
String decrypted = encryptor.decrypt(encrypted);
Assert.assertEquals(PLAIN_TEXT, decrypted);
}
}
示例9: getCode
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
private String getCode(String widgetId, boolean error) {
if (error) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append("<iframe src=\"");
String url = UrlUtil.getAppBaseUrl(storageService).
append("widget?id=").append(widgetId).
append("&width=").append(String.valueOf(width)).
append("&height=").append(String.valueOf(height)).
toString();
sb.append(url);
if (parameters == null) {
parameters = "";
}
if (!"".equals(parameters.trim())) {
String password = storageService.getSettings().getIframe().getEncryptionKey();
if ((password != null) && !password.trim().equals("")) {
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(password);
String myEncryptedText = textEncryptor.encrypt(parameters);
myEncryptedText = Base64.encodeBase64URLSafeString(myEncryptedText.getBytes());
sb.append("&P=").append(myEncryptedText);
} else {
sb.append("&").append(parameters);
}
}
sb.append("\" ");
sb.append("frameborder=0 ");
sb.append("width=").append(width).append("px ");
sb.append("height=").append(height).append("px");
sb.append("></iframe>");
return sb.toString();
}
示例10: encrypt
import org.jasypt.util.text.BasicTextEncryptor; //导入方法依赖的package包/类
@Override
public String encrypt(String privateKey, String value) {
BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword(privateKey);
return encryptor.encrypt(value);
}