deterministic_encryption_utils/encryption/Padding.py
def pad(data_to_pad, block_size, style='pkcs7'):
    """Apply standard padding.

    :Parameters:
      data_to_pad : byte string
        The data that needs to be padded.
      block_size : integer
        The block boundary to use for padding. The output length is guaranteed
        to be a multiple of ``block_size``.
      style : string
        Padding algorithm. It can be *'pkcs7'* (default), *'iso7816'* or *'x923'*.
    :Return:
      The original data with the appropriate padding added at the end.
    """

    padding_len = block_size-len(data_to_pad)%block_size
    if style == 'pkcs7':
        padding = bchr(padding_len)*padding_len
    elif style == 'x923':
        padding = bchr(0)*(padding_len-1) + bchr(padding_len)
    elif style == 'iso7816':
        padding = bchr(128) + bchr(0)*(padding_len-1)
    else:
        raise ValueError("Unknown padding style")
    return data_to_pad + padding
def pad(data_to_pad, block_size, style='pkcs7'):
    padding_len = block_size-len(data_to_pad)%block_size
    if style == 'pkcs7':
        padding = bchr(padding_len)*padding_len
    elif style == 'x923':
        padding = bchr(0)*(padding_len-1) + bchr(padding_len)
    elif style == 'iso7816':
        padding = bchr(128) + bchr(0)*(padding_len-1)
    else:
        raise ValueError("Unknown padding style")
    return data_to_pad + padding
def pad ( data_to_pad , block_size , style = 'pkcs7' ) : padding_len = block_size - len ( data_to_pad ) % block_size if style == 'pkcs7' : padding = bchr ( padding_len ) * padding_len elif style == 'x923' : padding = bchr ( 0 ) * ( padding_len - 1 ) + bchr ( padding_len ) elif style == 'iso7816' : padding = bchr ( 128 ) + bchr ( 0 ) * ( padding_len - 1 ) else : raise ValueError ( "Unknown padding style" ) return data_to_pad + padding
Apply standard padding.

    :Parameters:
      data_to_pad : byte string
        The data that needs to be padded.
      block_size : integer
        The block boundary to use for padding. The output length is guaranteed
        to be a multiple of ``block_size``.
      style : string
        Padding algorithm. It can be *'pkcs7'* (default), *'iso7816'* or *'x923'*.
    :Return:
      The original data with the appropriate padding added at the end.
Apply standard padding .