Skip to content

Instantly share code, notes, and snippets.

def main():
myMessage = input('Text to cipher: ').upper()
myKey = int(input('rail fence key: '))
ciphertext = transpoMessage(myKey, myMessage)
print(ciphertext)
def transpoMessage(key, plaintext):
ciphertext = [''] * key
for col in range(key):
pointer = col
@fadil703
fadil703 / XOR
Created February 25, 2019 03:45
1 0 1 1 0 0 1 0 1 1 0 1 1 1 <- Plain Text
1 1 0 1 0 0 0 1 1 0 1 0 0 1 <- Key
--------------------------- XOR enkripsi
0 1 1 0 0 0 1 1 0 1 1 1 1 0 <- cipher Text
1 1 0 1 0 0 0 1 1 0 1 0 0 1 <- Key
--------------------------- XOR dekripsi
1 0 1 1 0 0 1 0 1 1 0 1 1 1 <- Plain Text
from string import ascii_letters
cipher_letters = 'defghijklmnopqrstuvwxyzabcDEFGHIJKLMNOPQRSTUVWXYZABC'
trans = str.maketrans(ascii_letters, cipher_letters)
trans_rev = str.maketrans(cipher_letters, ascii_letters)
text_to_cipher = input('Text to cipher: ')
ciphered = text_to_cipher.translate(trans)