python - Add 1 bit to a string -
I'm looking for a path to add "1" for the message in Python, so that the MD5 algorithm Mentioned.
I did this, but the problem is that What should I do? use In Python 2.7, the letters 8 bits are large in each ASCII string. So with this method, you are not really adding "1 bit" every time, this is the reason that the left shift is required to do 1 times eight times otherwise you can change the msg is actually a string:
msg.append (0x01)
chr to convert the byte value to string. Then you can add them to
msg .
msg + = chr (0x01 & lt; 8) while len (msg)% 56! = 0: msg + = Chr (0x00)
0b10000000 instead of
0b00000001 < / Code> in the string.
Comments
Post a Comment