def appendPadding(str, blocksize=AES_blocksize, mode='CMS'):
  ''' Pad (append padding to) string for use with symmetric encryption algorithm
    Input: (string) str - String to be padded
           (int)    blocksize - block size of the encryption algorithm
           (string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random)
    Return:(string) Padded string according to chosen padding mode
  '''
  if mode not in (0,'CMS'):     
    for k in MODES.keys():
        if mode in k:
            return globals()['append'+k[1]+'Padding'](str, blocksize) 
        else:
            return appendCMSPadding(str, blocksize)
  else:
      return appendCMSPadding(str, blocksize)