本文整理匯總了Java中org.apache.sshd.common.cipher.TripleDESCBC類的典型用法代碼示例。如果您正苦於以下問題:Java TripleDESCBC類的具體用法?Java TripleDESCBC怎麽用?Java TripleDESCBC使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TripleDESCBC類屬於org.apache.sshd.common.cipher包,在下文中一共展示了TripleDESCBC類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: update
import org.apache.sshd.common.cipher.TripleDESCBC; //導入依賴的package包/類
public static byte[] update(Mode mode, String key, byte[] data) throws Exception
{
checkState(!isNullOrEmpty(key));
checkNotNull(data);
TripleDESCBC des = new TripleDESCBC();
des.init(mode, key.getBytes(), key.getBytes());
des.update(data, 0, data.length);
return data;
}
示例2: createCipherFactoryList
import org.apache.sshd.common.cipher.TripleDESCBC; //導入依賴的package包/類
/**
* create a list of factories from a list of cipher names
*/
@SuppressWarnings("unchecked")
public static List<NamedFactory<Cipher>> createCipherFactoryList(List<String> cipherNames) {
final NamedFactory<Cipher>[] cipherArray = new NamedFactory[] { //
//
new AES128CTR.Factory(), //
new AES256CTR.Factory(), //
new ARCFOUR128.Factory(), //
new ARCFOUR256.Factory(), //
new AES128CBC.Factory(), //
new TripleDESCBC.Factory(), //
new BlowfishCBC.Factory(), //
new AES192CBC.Factory(), //
new AES256CBC.Factory(), //
};
// first get all of the ciphers we know about in a set
final Map<String, NamedFactory<Cipher>> nameMap = new HashMap<>();
final boolean useDefaults;
if (cipherNames.size() <= 0) {
useDefaults = true;
cipherNames = new ArrayList<>(cipherArray.length);
} else {
useDefaults = false;
}
for (NamedFactory<Cipher> cipherFactory : cipherArray) {
nameMap.put(cipherFactory.getName(), cipherFactory);
if (useDefaults) {
cipherNames.add(cipherFactory.getName());
}
}
final List<NamedFactory<Cipher>> available = new ArrayList<>(cipherArray.length);
for (String cipherName : cipherNames) {
final NamedFactory<Cipher> factory = nameMap.get(cipherName);
if (null == factory) {
continue;
}
try {
final Cipher c = factory.create();
final byte[] key = new byte[c.getBlockSize()];
final byte[] iv = new byte[c.getIVSize()];
c.init(Cipher.Mode.Encrypt, key, iv);
available.add(factory);
} catch (Exception e) {
LOGGER.info("Failed to load cipher " + cipherName
+ " ensure you have the unlimited strength JCE installed");
}
}
return available;
}