Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getBinary(bitstr):
- bit=' '.join(format(ord(char), 'b') for char in bitstr)
- return bit
- def getChar(charstr):
- char = []
- for b in range(len(charstr) / 8):
- byte = charstr[b*8:(b+1)*8]
- char.append(chr(int(''.join([str(bit) for bit in byte]), 2)))
- return ''.join(chars)
- message="We attack at dawn!?*"
- key=2
- resp=getCaesar(message, key)
- print("Ciphertext: ")
- print(resp)
- print()
- bitstr=list(resp)
- binary=getBinary(bitstr)
- print("Binary: ")
- print(binary)
- print()
- charstr=getChar(binary)
- print("Char String: ")
- print(charstr)
- print()
- Ciphertext:
- Yg cvvcem cv fcyp#!,
- Binary:
- 1011001 1100111 100000 1100011 1110110 1110110 1100011 1100101 1101101 100000 1100011 1110110 100000 1100110 1100011 1111001 1110000 100011 100001 101100
- for b in range(len(charstr) / 8):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement