List of usage examples for org.bouncycastle.crypto StreamBlockCipher init
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException;
From source file:com.github.horrorho.inflatabledonkey.chunk.engine.ChunkDecrypters.java
License:Open Source License
public static Optional<byte[]> decrypt(byte[] key, StreamBlockCipher cipher, byte[] data, int offset, int length) { try {/* ww w . j a v a 2s .c o m*/ KeyParameter keyParameter = new KeyParameter(key); cipher.init(false, keyParameter); byte[] decrypted = new byte[length]; cipher.processBytes(data, offset, length, decrypted, 0); return Optional.of(decrypted); } catch (DataLengthException ex) { logger.warn("-- decrypt() - exception: ", ex); return Optional.empty(); } }
From source file:shadowsocks.crypto.AESCrypto.java
License:Apache License
@Override protected StreamCipher createCipher(byte[] iv, boolean encrypt) throws CryptoException { StreamBlockCipher c = getCipher(encrypt); ParametersWithIV parameterIV = new ParametersWithIV(new KeyParameter(mKey), iv, 0, mIVLength); c.init(encrypt, parameterIV); return c;/*from www .ja va2 s. c o m*/ }