本文整理汇总了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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}