PKCS#7 padding.

Extends self by appending the number of bytes of padding to the end of the block.

assert "YELLOW SUBMARINE".to_bytes.pkcs7(20) == "YELLOW SUBMARINE\x04\x04\x04\x04".to_bytes

Property definitions

crypto :: bytes $ Bytes :: pkcs7
	# PKCS#7 padding.
	#
	# Extends `self` by appending the number of bytes of padding to the end of the block.
	#
	#     assert "YELLOW SUBMARINE".to_bytes.pkcs7(20) == "YELLOW SUBMARINE\x04\x04\x04\x04".to_bytes
	fun pkcs7(blocksize: Int): Bytes
	do
		var mod = length % blocksize
		if mod == 0 then return self
		var pad = blocksize - mod
		var byte = pad
		for i in [0..pad[ do add byte
		return self
	end
lib/crypto/bytes.nit:19,2--32,4