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


Java PKCS7Padding类代码示例

本文整理汇总了Java中org.spongycastle.crypto.paddings.PKCS7Padding的典型用法代码示例。如果您正苦于以下问题:Java PKCS7Padding类的具体用法?Java PKCS7Padding怎么用?Java PKCS7Padding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createCipher

import org.spongycastle.crypto.paddings.PKCS7Padding; //导入依赖的package包/类
protected PaddedBufferedBlockCipher createCipher(String passphrase, boolean isEncrypting) throws CryptoException{
	CustomRandom cRandom = new CustomRandom(utf8Bytes(passphrase));
	byte[] salt = new byte[8];
	cRandom.nextBytes(salt);
	byte[] password = new byte[32];
	cRandom.nextBytes(password);
	int iterationCount = 1000;
	int keyLength = 256;		
	int blockSize = 128;
	
	PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA256Digest());
	generator.init(password, salt, iterationCount);

	CipherParameters key = generator
				.generateDerivedParameters(keyLength, blockSize);
	
	CBCBlockCipher cbcCipher = new CBCBlockCipher(new AESEngine());
	PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(
			cbcCipher, new PKCS7Padding());
	cipher.init(isEncrypting, key);
	return cipher;
}
 
开发者ID:micheal-swiggs,项目名称:jumblar,代码行数:23,代码来源:WeakSymmetricEncryption.java

示例2: createAes128CtrPkcs7PaddingCipher

import org.spongycastle.crypto.paddings.PKCS7Padding; //导入依赖的package包/类
static PaddedBufferedBlockCipher createAes128CtrPkcs7PaddingCipher(
        boolean encrypting,
        byte[] iv,
        byte[] key) {
    AESEngine aes = new AESEngine();
    SICBlockCipher aesCtr = new SICBlockCipher(aes);
    PaddedBufferedBlockCipher aesCtrPkcs7 =
            new PaddedBufferedBlockCipher(aesCtr, new PKCS7Padding());
    aesCtrPkcs7.init(encrypting, new ParametersWithIV(new KeyParameter(key), iv));

    return aesCtrPkcs7;
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:13,代码来源:IoUtil.java

示例3: encrypt

import org.spongycastle.crypto.paddings.PKCS7Padding; //导入依赖的package包/类
public static byte[] encrypt(byte[] key, byte[] input) throws DataLengthException, InvalidCipherTextException {
	pbbc = new PaddedBufferedBlockCipher(AESCipher, new PKCS7Padding());
	AESSpongeyCastle.key = new KeyParameter(key);
    return processing(input, true);
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:6,代码来源:AESSpongeyCastle.java

示例4: decrypt

import org.spongycastle.crypto.paddings.PKCS7Padding; //导入依赖的package包/类
public static byte[] decrypt(byte[] key, byte[] input) throws DataLengthException, InvalidCipherTextException {
	pbbc = new PaddedBufferedBlockCipher(AESCipher, new PKCS7Padding());
	AESSpongeyCastle.key = new KeyParameter(key);
    return processing(input, false);
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:6,代码来源:AESSpongeyCastle.java

示例5: encrypt

import org.spongycastle.crypto.paddings.PKCS7Padding; //导入依赖的package包/类
public static byte[] encrypt(byte[] key, byte[] input) throws DataLengthException, InvalidCipherTextException {
	pbbc = new PaddedBufferedBlockCipher(ThreefishCipher, new PKCS7Padding());
	ThreefishSpongeyCastle.key = new KeyParameter(key);
    return processing(input, true);
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:6,代码来源:ThreefishSpongeyCastle.java

示例6: decrypt

import org.spongycastle.crypto.paddings.PKCS7Padding; //导入依赖的package包/类
public static byte[] decrypt(byte[] key, byte[] input) throws DataLengthException, InvalidCipherTextException {
	pbbc = new PaddedBufferedBlockCipher(ThreefishCipher, new PKCS7Padding());
	ThreefishSpongeyCastle.key = new KeyParameter(key);
    return processing(input, false);
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:6,代码来源:ThreefishSpongeyCastle.java


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