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


Java Base64.decode方法代码示例

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


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

示例1: readPKCS8Key

import com.trilead.ssh2.crypto.Base64; //导入方法依赖的package包/类
private KeyPair readPKCS8Key(byte[] keyData) {
	BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(keyData)));

	// parse the actual key once to check if its encrypted
	// then save original file contents into our database
	try {
		ByteArrayOutputStream keyBytes = new ByteArrayOutputStream();

		String line;
		boolean inKey = false;
		while ((line = reader.readLine()) != null) {
			if (line.equals(PubkeyUtils.PKCS8_START)) {
				inKey = true;
			} else if (line.equals(PubkeyUtils.PKCS8_END)) {
				break;
			} else if (inKey) {
				keyBytes.write(line.getBytes("US-ASCII"));
			}
		}

		if (keyBytes.size() > 0) {
			byte[] decoded = Base64.decode(keyBytes.toString().toCharArray());

			return PubkeyUtils.recoverKeyPair(decoded);
		}
	} catch (Exception e) {
		return null;
	}
	return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:PubkeyListActivity.java

示例2: initialize

import com.trilead.ssh2.crypto.Base64; //导入方法依赖的package包/类
private void initialize(char[] knownHostsData) throws IOException
{
	BufferedReader br = new BufferedReader(new CharArrayReader(knownHostsData));

	while (true)
	{
		String line = br.readLine();

		if (line == null)
			break;

		line = line.trim();

		if (line.startsWith("#"))
			continue;

		String[] arr = line.split(" ");

		if (arr.length >= 3)
		{
			if ((arr[1].compareTo("ssh-rsa") == 0) || (arr[1].compareTo("ssh-dss") == 0))
			{
				String[] hostnames = arr[0].split(",");

				byte[] msg = Base64.decode(arr[2].toCharArray());

				addHostkey(hostnames, arr[1], msg);
			}
		}
	}
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:32,代码来源:KnownHosts.java

示例3: checkHashed

import com.trilead.ssh2.crypto.Base64; //导入方法依赖的package包/类
private final boolean checkHashed(String entry, String hostname)
{
	if (entry.startsWith("|1|") == false)
		return false;

	int delim_idx = entry.indexOf('|', 3);

	if (delim_idx == -1)
		return false;

	String salt_base64 = entry.substring(3, delim_idx);
	String hash_base64 = entry.substring(delim_idx + 1);

	byte[] salt = null;
	byte[] hash = null;

	try
	{
		salt = Base64.decode(salt_base64.toCharArray());
		hash = Base64.decode(hash_base64.toCharArray());
	}
	catch (IOException e)
	{
		return false;
	}

	SHA1 sha1 = new SHA1();

	if (salt.length != sha1.getDigestLength())
		return false;

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

	for (int i = 0; i < dig.length; i++)
		if (dig[i] != hash[i])
			return false;

	return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:KnownHosts.java

示例4: checkHashed

import com.trilead.ssh2.crypto.Base64; //导入方法依赖的package包/类
private final boolean checkHashed(String entry, String hostname) {
	if (entry.startsWith("|1|") == false)
		return false;

	int delim_idx = entry.indexOf('|', 3);

	if (delim_idx == -1)
		return false;

	String salt_base64 = entry.substring(3, delim_idx);
	String hash_base64 = entry.substring(delim_idx + 1);

	byte[] salt = null;
	byte[] hash = null;

	try {
		salt = Base64.decode(salt_base64.toCharArray());
		hash = Base64.decode(hash_base64.toCharArray());
	} catch (IOException e) {
		return false;
	}

	SHA1 sha1 = new SHA1();

	if (salt.length != sha1.getDigestLength())
		return false;

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

	for (int i = 0; i < dig.length; i++)
		if (dig[i] != hash[i])
			return false;

	return true;
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:36,代码来源:KnownHosts.java

示例5: initialize

import com.trilead.ssh2.crypto.Base64; //导入方法依赖的package包/类
private void initialize(char[] knownHostsData) throws IOException {
	BufferedReader br = new BufferedReader(new CharArrayReader(
			knownHostsData));

	while (true) {
		String line = br.readLine();

		if (line == null)
			break;

		line = line.trim();

		if (line.startsWith("#"))
			continue;

		String[] arr = line.split(" ");

		if (arr.length >= 3) {
			if ((arr[1].compareTo("ssh-rsa") == 0)
					|| (arr[1].compareTo("ssh-dss") == 0)) {
				String[] hostnames = arr[0].split(",");

				byte[] msg = Base64.decode(arr[2].toCharArray());

				addHostkey(hostnames, arr[1], msg);
			}
		}
	}
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:30,代码来源:KnownHosts.java


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