当前位置: 首页>>代码示例>>Java>>正文


Java BasicTextEncryptor.encrypt方法代码示例

本文整理汇总了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");
	}
}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:25,代码来源:MirrorMakerAgent.java

示例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, "");
        }
    }
}
 
开发者ID:GlitchCog,项目名称:ChatGameFontificator,代码行数:23,代码来源:FontificatorProperties.java

示例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);
}
 
开发者ID:SchweizerischeBundesbahnen,项目名称:releasetrain,代码行数:9,代码来源:EncryptorImpl.java

示例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);
}
 
开发者ID:jandy-team,项目名称:jandy,代码行数:14,代码来源:Main.java

示例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);
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:15,代码来源:PasswordManagerTest.java

示例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 + ")");
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:11,代码来源:DecryptConverterTest.java

示例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);
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:13,代码来源:SecurityServiceProviderUtility.java

示例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);
    }
}
 
开发者ID:debop,项目名称:debop4j,代码行数:15,代码来源:JasyptTest.java

示例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("&lt;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(">&lt;/iframe&gt;");
	return sb.toString();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:41,代码来源:WidgetEmbedCodePanel.java

示例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);
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:7,代码来源:CryptoServiceImpl.java


注:本文中的org.jasypt.util.text.BasicTextEncryptor.encrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。