1. KMatle

    B4J Tutorial [B4x]Padding/depadding PKCS7/5 and other

    EDIT: If the message length is equal to the pad length, you have to pad to the next multiple. E.g. 16 bytes would be padded to 32 because one would not know how long the message was because the last byte defines the number of added (=padded) values. Here's another example to pad/depad data for...
  2. KMatle

    Android Code Snippet [B4x] Padding data (e.g. building blocks of a multiple of 16)

    For some solutions you need to pad data to a specific length (=blocksize or a multiple of x, like a multiple of 16 in AES). This snippet gets the next higher multiple of the padding. If your data is 5 bytes long, the blocksize would be 16, having 17 bytes it would be 32. Dim PadTo As Int = 16...