def append_PKCS7_padding(val):
    """ Function to pad the given data to a multiple of 16-bytes by PKCS7 padding. """
    
    numpads = 16 - (len(val) % 16)
    return val + numpads * bytes(chr(numpads), 'utf-8')