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


Java Base64.encode方法代码示例

本文整理汇总了Java中ch.ethz.ssh2.crypto.Base64.encode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.encode方法的具体用法?Java Base64.encode怎么用?Java Base64.encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.ethz.ssh2.crypto.Base64的用法示例。


在下文中一共展示了Base64.encode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHashedHostname

import ch.ethz.ssh2.crypto.Base64; //导入方法依赖的package包/类
/**
 * Generate the hashed representation of the given hostname. Useful for adding entries
 * with hashed hostnames to a known_hosts file. (see -H option of OpenSSH key-gen).
 *  
 * @param hostname
 * @return the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA="
 */
public static final String createHashedHostname(String hostname)
{
	SHA1 sha1 = new SHA1();

	byte[] salt = new byte[sha1.getDigestLength()];

	new SecureRandom().nextBytes(salt);

	byte[] hash = hmacSha1Hash(salt, hostname);

	String base64_salt = new String(Base64.encode(salt));
	String base64_hash = new String(Base64.encode(hash));

	return new String("|1|" + base64_salt + "|" + base64_hash);
}
 
开发者ID:mattb243,项目名称:AmazonEC2Matlab,代码行数:23,代码来源:KnownHosts.java

示例2: createHashedHostname

import ch.ethz.ssh2.crypto.Base64; //导入方法依赖的package包/类
/**
 * Generate the hashed representation of the given hostname. Useful for adding entries
 * with hashed hostnames to a known_hosts file. (see -H option of OpenSSH key-gen).
 *
 * @param hostname
 * @return the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA="
 */
public static final String createHashedHostname(String hostname) {
    SHA1 sha1 = new SHA1();

    byte[] salt = new byte[sha1.getDigestLength()];

    new SecureRandom().nextBytes(salt);

    byte[] hash = hmacSha1Hash(salt, hostname);

    String base64_salt = new String(Base64.encode(salt));
    String base64_hash = new String(Base64.encode(hash));

    return new String("|1|" + base64_salt + "|" + base64_hash);
}
 
开发者ID:fast-data-transfer,项目名称:fdt,代码行数:22,代码来源:KnownHosts.java

示例3: execute

import ch.ethz.ssh2.crypto.Base64; //导入方法依赖的package包/类
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	LogonForm logonForm = (LogonForm) form;

	// 取得登入的使用者帳號密碼
	String userId = logonForm.getUserId();
	String password = logonForm.getPassword();

	log.debug("LogonForm.UserID=" + userId);

	// 建立User Session
	IUserSession userSession = ProjectInfoCenter.getInstance().login(userId, password);

	String encodedPassword = new String(Base64.encode(password.getBytes()));

	// 設定權限資訊
	AccessPermissionManager.setupPermission(request, userSession);

	// 設定User Session
	request.getSession().setAttribute("UserSession", userSession);

	// 為了要讓插件中可以使用session的中使用者的密碼,所以將原本利用MD5加密的密碼轉換成利用Base64加密。如此加密的密碼才可逆
	request.getSession().setAttribute("passwordForPlugin", encodedPassword);

	ProjectLogic projectLogic = new ProjectLogic();
	projectLogic.cloneDefaultFile();

	Person person = this.getPerson(userSession.getAccount());
	
	return mapping.findForward(person.getForwardName());
}
 
开发者ID:ezScrum,项目名称:ezScrum,代码行数:31,代码来源:LogonSubmitAction.java


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