Java 类org.bouncycastle.crypto.engines.RijndaelEngine 实例源码

项目:ExamplesAndroid    文件:Metodos.java   
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;
}
项目:jsendnsca    文件:AESEncryptor.java   
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);
    }
}
项目:CryptoKnight    文件:Encryptor.java   
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();       
}
项目:ipack    文件:Rijndael.java   
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new RijndaelEngine();
        }
    });
}
项目:Aki-SSL    文件:Rijndael.java   
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new RijndaelEngine();
        }
    });
}
项目:ExamplesAndroid    文件:Metodos.java   
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;
    }
项目:CryptMeme    文件:Rijndael.java   
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new RijndaelEngine();
        }
    });
}
项目:irma_future_id    文件:Rijndael.java   
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new RijndaelEngine();
        }
    });
}
项目:bc-java    文件:Rijndael.java   
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new RijndaelEngine();
        }
    });
}
项目:gwt-crypto    文件:RijndaelTest.java   
RijndaelTest()
{
    super(tests, new RijndaelEngine(128), new KeyParameter(new byte[16]));
}
项目:Proxy    文件:EncryptionHandler.java   
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;
}
项目:irma_future_id    文件:RijndaelTest.java   
RijndaelTest()
{
    super(tests, new RijndaelEngine(128), new KeyParameter(new byte[16]));
}
项目:bc-java    文件:RijndaelTest.java   
RijndaelTest()
{
    super(tests, new RijndaelEngine(128), new KeyParameter(new byte[16]));
}