本文整理汇总了Java中com.jcraft.jsch.Cipher类的典型用法代码示例。如果您正苦于以下问题:Java Cipher类的具体用法?Java Cipher怎么用?Java Cipher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cipher类属于com.jcraft.jsch包,在下文中一共展示了Cipher类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
byte[] tmp;
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
cipher=javax.crypto.Cipher.getInstance("RC4");
SecretKeySpec _key = new SecretKeySpec(key, "RC4");
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
_key);
byte[] foo=new byte[1];
for(int i=0; i<skip; i++){
cipher.update(foo, 0, 1, foo, 0);
}
}
catch(Exception e){
cipher=null;
throw e;
}
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:25,代码来源:ARCFOUR256.java
示例2: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
String pad="NoPadding";
byte[] tmp;
if(iv.length>ivsize){
tmp=new byte[ivsize];
System.arraycopy(iv, 0, tmp, 0, tmp.length);
iv=tmp;
}
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
SecretKeySpec keyspec=new SecretKeySpec(key, "AES");
cipher=javax.crypto.Cipher.getInstance("AES/CBC/"+pad);
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
keyspec, new IvParameterSpec(iv));
}
catch(Exception e){
cipher=null;
throw e;
}
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:27,代码来源:AES192CBC.java
示例3: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
String pad="NoPadding";
byte[] tmp;
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
cipher=javax.crypto.Cipher.getInstance("RC4");
SecretKeySpec _key = new SecretKeySpec(key, "RC4");
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
_key);
}
catch(Exception e){
cipher=null;
throw e;
}
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:23,代码来源:ARCFOUR.java
示例4: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
String pad="NoPadding";
byte[] tmp;
if(iv.length>ivsize){
tmp=new byte[ivsize];
System.arraycopy(iv, 0, tmp, 0, tmp.length);
iv=tmp;
}
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
SecretKeySpec keyspec=new SecretKeySpec(key, "AES");
cipher=javax.crypto.Cipher.getInstance("AES/CTR/"+pad);
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
keyspec, new IvParameterSpec(iv));
}
catch(Exception e){
cipher=null;
throw e;
}
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:27,代码来源:AES192CTR.java
示例5: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
String pad="NoPadding";
// if(padding) pad="PKCS5Padding";
byte[] tmp;
if(iv.length>ivsize){
tmp=new byte[ivsize];
System.arraycopy(iv, 0, tmp, 0, tmp.length);
iv=tmp;
}
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish");
cipher=javax.crypto.Cipher.getInstance("Blowfish/CBC/"+pad);
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
skeySpec, new IvParameterSpec(iv));
}
catch(Exception e){
throw e;
}
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:27,代码来源:BlowfishCBC.java
示例6: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
byte[] tmp;
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
cipher=javax.crypto.Cipher.getInstance("RC4");
SecretKeySpec _key = new SecretKeySpec(key, "RC4");
synchronized(javax.crypto.Cipher.class){
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
_key);
}
byte[] foo=new byte[1];
for(int i=0; i<skip; i++){
cipher.update(foo, 0, 1, foo, 0);
}
}
catch(Exception e){
cipher=null;
throw e;
}
}
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:27,代码来源:ARCFOUR256.java
示例7: init
import com.jcraft.jsch.Cipher; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv) throws Exception{
String pad="NoPadding";
byte[] tmp;
if(key.length>bsize){
tmp=new byte[bsize];
System.arraycopy(key, 0, tmp, 0, tmp.length);
key=tmp;
}
try{
cipher=javax.crypto.Cipher.getInstance("RC4");
SecretKeySpec _key = new SecretKeySpec(key, "RC4");
synchronized(javax.crypto.Cipher.class){
cipher.init((mode==ENCRYPT_MODE?
javax.crypto.Cipher.ENCRYPT_MODE:
javax.crypto.Cipher.DECRYPT_MODE),
_key);
}
}
catch(Exception e){
cipher=null;
throw e;
}
}
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:25,代码来源:ARCFOUR.java
注:本文中的com.jcraft.jsch.Cipher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论