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


Java RijndaelEngine类代码示例

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


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

示例1: testEncryptRijndael

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
public String testEncryptRijndael(String value,String key) throws DataLengthException, IllegalStateException, InvalidCipherTextException {
    BlockCipher engine = new RijndaelEngine(256);
    BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(engine), new ZeroBytePadding());

    byte[] keyBytes = key.getBytes();
    cipher.init(true, new KeyParameter(keyBytes));

    byte[] input = value.getBytes();
    byte[] cipherText = new byte[cipher.getOutputSize(input.length)];

    int cipherLength = cipher.processBytes(input, 0, input.length, cipherText, 0);
    cipher.doFinal(cipherText, cipherLength);

    String result = new String(Base64.encode(cipherText));
    //Log.e("testEncryptRijndael : " , result);
    return  result;
}
 
开发者ID:David-Hackro,项目名称:ExamplesAndroid,代码行数:18,代码来源:Metodos.java

示例2: encrypt

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
public void encrypt(byte[] passiveCheckBytes, byte[] initVector, String password) {
    RijndaelEngine engine = new RijndaelEngine(_keyByteLength * 8);
    PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CFBBlockCipher(engine, 8), new ZeroBytePadding());

    try {
        byte[] sessionKey = new byte[_keyByteLength];
        byte[] passwordBytes = password.getBytes("US-ASCII");
        System.arraycopy(passwordBytes, 0, sessionKey, 0, Math.min(_keyByteLength, passwordBytes.length));

        byte[] iv = new byte[_keyByteLength];
        System.arraycopy(initVector, 0, iv, 0, Math.min(_keyByteLength, initVector.length));

        cipher.init(true, new ParametersWithIV(new KeyParameter(sessionKey), iv));

        byte[] cipherText = new byte[cipher.getOutputSize(passiveCheckBytes.length)];
        int cipherLength = cipher.processBytes(passiveCheckBytes, 0, passiveCheckBytes.length, cipherText, 0);
        cipherLength = cipherLength + cipher.doFinal(cipherText, cipherLength);

        int bytesToCopy = Math.min(passiveCheckBytes.length, cipherLength);
        System.arraycopy(cipherText, 0, passiveCheckBytes, 0, bytesToCopy);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:25,代码来源:AESEncryptor.java

示例3: setParameters

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
public void setParameters(int KeySize, int alg) throws NoSuchAlgorithmException, InvalidKeySpecException
{
	switch (alg)
	{
	case 7:
	case 1:
		this.blockSize = KeySize;
		break;
		
	case 8:
		this.blockSize = 256;
		break;
		
	default:
		this.blockSize = 128;
		break;
	}
	
	switch (KeySize)
	{
	case 128:
	case 192:
		Algs[1] = new RijndaelEngine(KeySize);
		break;
	
	case 256:
		Algs[1] = new RijndaelEngine(KeySize);
		Algs[7] = new ThreefishEngine(KeySize);
		break;
	
	default:
		Algs[7] = new ThreefishEngine(KeySize);
		break;
	}
	
	padding = new PKCS7Padding();		
}
 
开发者ID:MonroCoury,项目名称:CryptoKnight,代码行数:38,代码来源:Encryptor.java

示例4: ECB

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new RijndaelEngine();
        }
    });
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:11,代码来源:Rijndael.java

示例5: testDecryptRijndael

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
public String testDecryptRijndael(String value,String key) throws DataLengthException, IllegalStateException, InvalidCipherTextException {
        BlockCipher engine = new RijndaelEngine(256);
        BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(engine), new ZeroBytePadding());

        byte[] keyBytes = key.getBytes();
        cipher.init(false, new KeyParameter(keyBytes));

        byte[] output = Base64.decode(value.getBytes());
        byte[] cipherText = new byte[cipher.getOutputSize(output.length)];

        int cipherLength = cipher.processBytes(output, 0, output.length, cipherText, 0);
        int outputLength = cipher.doFinal(cipherText, cipherLength);
        outputLength += cipherLength;

        byte[] resultBytes = cipherText;
        if (outputLength != output.length) {
            resultBytes = new byte[outputLength];
            System.arraycopy(
                    cipherText, 0,
                    resultBytes, 0,
                    outputLength
            );
        }

        String result = new String(resultBytes);
return  result;
    }
 
开发者ID:David-Hackro,项目名称:ExamplesAndroid,代码行数:28,代码来源:Metodos.java

示例6: RijndaelTest

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
RijndaelTest()
{
    super(tests, new RijndaelEngine(128), new KeyParameter(new byte[16]));
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:5,代码来源:RijndaelTest.java

示例7: createCipher

import org.bouncycastle.crypto.engines.RijndaelEngine; //导入依赖的package包/类
private BufferedBlockCipher createCipher( boolean encryptor, byte[] key, byte[] iv ) {
    BufferedBlockCipher cipher = new BufferedBlockCipher( new CFBBlockCipher( new RijndaelEngine( 128 ), 8 ) );
    cipher.init( encryptor, new ParametersWithIV( new KeyParameter( key ), iv ) );
    return cipher;
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:6,代码来源:EncryptionHandler.java


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