def appendBitPadding(str, blocksize=AES_blocksize):
  '''Bit padding a.k.a. One and Zeroes Padding
  A single set ('1') bit is added to the message and then as many reset ('0') bits as required (possibly none) are added.
  Input: (str) str - String to be padded
         (int) blocksize - block size of the algorithm
  Return: Padded string according to ANSI X.923 standart

  Used in when padding bit strings.
  0x80 in binary is 10000000
  0x00 in binary is 00000000

  Defined in ANSI X.923 (based on NIST Special Publication 800-38A) and ISO/IEC 9797-1 as Padding Method 2.
  Used in hash functions MD5 and SHA, described in RFC 1321 step 3.1.
  '''
  pad_len = 1 - paddingLength(len(str), blocksize)
   
  padding = chr(0x80)+'\0'*pad_len
  
  return str + padding
dataset/ETHPy150Open keenlabs/KeenClient-Python/keen/Padding.py/appendBitPadding/swapped operands of `-`