protected static long[] bytesToLongs(final byte[] ba) { return bytesToLongs(ba, 0, ba.length); } /**
/** * Initializes cipher in a simple way. */ public void init(final String keyMessage, final long tweak1, final long tweak2) { long[] tweak = new long[] {tweak1, tweak2}; byte[] key = new byte[blockSize / Byte.SIZE]; byte[] keyData = StringUtil.getBytes(keyMessage); System.arraycopy(keyData, 0, key, 0, key.length < keyData.length ? key.length : keyData.length); init(bytesToLongs(key), tweak); }
/** * Encrypts a block. */ @Override public byte[] encryptBlock(final byte[] content, final int offset) { long[] contentBlock = bytesToLongs(content, offset, blockSizeInBytes); long[] encryptedBlock = new long[blockSize / Long.SIZE]; blockEncrypt(contentBlock, encryptedBlock); return longsToBytes(encryptedBlock); }
@Override public byte[] decryptBlock(final byte[] encryptedContent, final int offset) { long[] encryptedBlock = bytesToLongs(encryptedContent, offset, blockSizeInBytes); long[] decryptedBlock= new long[encryptedBlock.length]; blockDecrypt(encryptedBlock, decryptedBlock); return longsToBytes(decryptedBlock); }
protected static long[] bytesToLongs(final byte[] ba) { return bytesToLongs(ba, 0, ba.length); } /**
/** * Initializes cipher in a simple way. */ public void init(final String keyMessage, final long tweak1, final long tweak2) { long[] tweak = new long[] {tweak1, tweak2}; byte[] key = new byte[blockSize / Byte.SIZE]; byte[] keyData = StringUtil.getBytes(keyMessage); System.arraycopy(keyData, 0, key, 0, key.length < keyData.length ? key.length : keyData.length); init(bytesToLongs(key), tweak); }
@Override public byte[] decryptBlock(final byte[] encryptedContent, final int offset) { long[] encryptedBlock = bytesToLongs(encryptedContent, offset, blockSizeInBytes); long[] decryptedBlock= new long[encryptedBlock.length]; blockDecrypt(encryptedBlock, decryptedBlock); return longsToBytes(decryptedBlock); }
/** * Encrypts a block. */ @Override public byte[] encryptBlock(final byte[] content, final int offset) { long[] contentBlock = bytesToLongs(content, offset, blockSizeInBytes); long[] encryptedBlock = new long[blockSize / Long.SIZE]; blockEncrypt(contentBlock, encryptedBlock); return longsToBytes(encryptedBlock); }