List of usage examples for java.util BitSet valueOf
public static BitSet valueOf(ByteBuffer bb)
From source file:uk.co.infinityapps.rehpic.cipherblockmode.CipherBlockChainingMode.java
private byte[] xorCipherAndPlainText(byte[] cipherText, byte[] plainText) { final BitSet cipherTextBitSet = BitSet.valueOf(cipherText); final BitSet plainTextBitSet = BitSet.valueOf(plainText); cipherTextBitSet.xor(plainTextBitSet); return BitUtils.bitSetToByteArray(cipherTextBitSet, cipherText.length); }
From source file:uk.co.infinityapps.rehpic.round.RoundFunctionImpl.java
public byte[] encrypt(byte[] blockData, final byte[][] subKeys) { for (byte[] subKey : subKeys) { blockData = mixingPermutator.mix(blockData); blockData = permutator.shiftLeft(blockData, subKey); final BitSet blockBitSet = BitSet.valueOf(blockData); blockBitSet.xor(BitSet.valueOf(subKey)); blockData = substitutionBox.subtitute(BitUtils.bitSetToByteArray(blockBitSet, blockData.length), subKey);//from w w w. j a v a2s . c om } return blockData; }
From source file:uk.co.infinityapps.rehpic.round.RoundFunctionImpl.java
public byte[] decrypt(byte[] blockData, final byte[][] subKeys) { final byte[][] reversedSubKeys = reverseSubKeysForDecryption(subKeys); for (byte[] subKey : reversedSubKeys) { blockData = substitutionBox.subtitute(blockData, subKey); BitSet xorBlockBitSet = BitSet.valueOf(blockData); xorBlockBitSet.xor(BitSet.valueOf(subKey)); blockData = permutator.shiftRight(BitUtils.bitSetToByteArray(xorBlockBitSet, blockData.length), subKey); blockData = mixingPermutator.unmix(blockData); }//from w w w.j a v a2 s. c om return blockData; }