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 msg is actually a string:

  msg.append (0x01)   

What should I do?

use 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)   

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 0b10000000 instead of 0b00000001 < / Code> in the string.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -