Ejemplo n.º 1
0
def pad_aes256(s):
    """
    Pads an input string to a given block size.
    :param s: string
    :returns: The padded string.
    """
    if len(s) % AES.block_size == 0:
        return s

    return Padding.appendPadding(s, blocksize=AES.block_size)
Ejemplo n.º 2
0
def old_pad(s):
    """
    Pads an input string to a given block size.
    :param s: string
    :returns: The padded string.
    """
    if len(s) % OLD_BLOCK_SIZE == 0:
        return s

    return Padding.appendPadding(s, blocksize=OLD_BLOCK_SIZE)
Ejemplo n.º 3
0
def old_pad(s):
    """
    Pads an input string to a given block size.
    :param s: string
    :returns: The padded string.
    """
    if len(s) % OLD_BLOCK_SIZE == 0:
        return s

    return Padding.appendPadding(s, blocksize=OLD_BLOCK_SIZE)
Ejemplo n.º 4
0
def pad_aes256(s):
    """
    Pads an input string to a given block size.
    :param s: string
    :returns: The padded string.
    """
    if len(s) % AES.block_size == 0:
        return s

    return Padding.appendPadding(s, blocksize=AES.block_size)
Ejemplo n.º 5
0
def old_unpad(s):
    """
    Removes padding from an input string based on a given block size.
    :param s: string
    :returns: The unpadded string.
    """
    if not s:
        return s

    try:
        return Padding.removePadding(s, blocksize=OLD_BLOCK_SIZE)
    except AssertionError:
        # if there's an error while removing padding, just return s.
        return s
Ejemplo n.º 6
0
def unpad_aes256(s):
    """
    Removes padding from an input string based on a given block size.
    :param s: string
    :returns: The unpadded string.
    """
    if not s:
        return s

    try:
        return Padding.removePadding(s, blocksize=AES.block_size)
    except AssertionError:
        # if there's an error while removing padding, just return s.
        return s
Ejemplo n.º 7
0
def old_unpad(s):
    """
    Removes padding from an input string based on a given block size.
    :param s: string
    :returns: The unpadded string.
    """
    if not s:
        return s

    try:
        return Padding.removePadding(s, blocksize=OLD_BLOCK_SIZE)
    except AssertionError:
        # if there's an error while removing padding, just return s.
        return s
Ejemplo n.º 8
0
def unpad_aes256(s):
    """
    Removes padding from an input string based on a given block size.
    :param s: string
    :returns: The unpadded string.
    """
    if not s:
        return s

    try:
        return Padding.removePadding(s, blocksize=AES.block_size)
    except AssertionError:
        # if there's an error while removing padding, just return s.
        return s