jodd-core/src/main/java/jodd/crypt/BlockCipher.java
public byte[] encrypt(final byte[] content) {
		FastByteBuffer fbb = new FastByteBuffer();

		int length = content.length + 1;
		int blockCount = length / blockSizeInBytes;
		int remaining = length;

		int offset = 0;
		for (int i = 0; i < blockCount; i++) {
			if (remaining == blockSizeInBytes) {
				break;
			}
			byte[] encrypted = encryptBlock(content, offset);

			fbb.append(encrypted);

			offset += blockSizeInBytes;
			remaining -= blockSizeInBytes;
		}

		if (remaining != 0) {
			// process remaining bytes
			byte[] block = new byte[blockSizeInBytes];

			System.arraycopy(content, offset, block, 0, remaining - 1);

			block[remaining - 1] = TERMINATOR;

			byte[] encrypted = encryptBlock(block, 0);

			fbb.append(encrypted);
		}

		return fbb.toArray();
	}
public byte[] encrypt(final byte[] content) {
		FastByteBuffer fbb = new FastByteBuffer();

		int length = content.length + 1;
		int blockCount = length / blockSizeInBytes;
		int remaining = length;

		int offset = 0;
		for (int i = 0; i < blockCount; i++) {
			if (remaining == blockSizeInBytes) {
				break;
			}
			byte[] encrypted = encryptBlock(content, offset);

			fbb.append(encrypted);

			offset += blockSizeInBytes;
			remaining -= blockSizeInBytes;
		}

		if (remaining != 0) {
			// process remaining bytes
			byte[] block = new byte[blockSizeInBytes];

			System.arraycopy(content, offset, block, 0, remaining - 1);

			block[remaining - 1] = TERMINATOR;

			byte[] encrypted = encryptBlock(block, 0);

			fbb.append(encrypted);
		}

		return fbb.toArray();
	}
public byte [ ] encrypt ( final byte [ ] content ) { FastByteBuffer fbb = new FastByteBuffer ( ) ; int length = content . length + 1 ; int blockCount = length / blockSizeInBytes ; int remaining = length ; int offset = 0 ; for ( int i = 0 ; i < blockCount ; i ++ ) { if ( remaining == blockSizeInBytes ) { break ; } byte [ ] encrypted = encryptBlock ( content , offset ) ; fbb . append ( encrypted ) ; offset += blockSizeInBytes ; remaining -= blockSizeInBytes ; } if ( remaining != 0 ) { // process remaining bytes byte [ ] block = new byte [ blockSizeInBytes ] ; System . arraycopy ( content , offset , block , 0 , remaining - 1 ) ; block [ remaining - 1 ] = TERMINATOR ; byte [ ] encrypted = encryptBlock ( block , 0 ) ; fbb . append ( encrypted ) ; } return fbb . toArray ( ) ; }
Encrypts complete content, block by block.
Encrypts complete content block by block .