编辑:我明白了。这是我使用的代码。
def bitshiftEncrypt(word):
newWord = ""
for i in word:
shift = '{:07b}'.format(ord(i)+1)
newShift = shift[1:]
newShift += shift[0]
newWord += chr(int(newShift,2))
print(newWord)
def bitshiftDecrypt(word):
newWord = ""
for i in word:
shift = '{:07b}'.format(ord(i))
newShift = shift[len(str(shift))-1]
newShift += shift[:-1:1]
newWord += str(chr(int(newShift,2)-1))
print(newWord)
感谢您的帮助!
答案 0 :(得分:0)
bin()
将为您提供最短的代表性。这将以各种方式阻止你。
3>> bin(3)
'0b11'
3>> '{:07b}'.format(3)
'0000011'