Closed mattbruv closed 4 years ago
Hi, @mattbruv !
This doesn't work because the default alphabet doesn't have 'spaces'. If you remove all spaces in msg
the code works.
Also, you can use NoSpaces
, it removes spaces from message:
from secretpy import Autokey
from secretpy import CryptMachine
from secretpy.cmdecorators import UpperCase, SaveSpaces, NoSpaces
from secretpy import alphabets
cipher = Autokey()
key = "test"
msg = "this is a secret message"
cm = NoSpaces(CryptMachine(cipher, key))
out = cm.encrypt(msg)
print(out)
output:
mlalbzikmurwxovwlmkw
And if you want save the spaces in message you can use SaveSpaces
:
from secretpy import Autokey
from secretpy import CryptMachine
from secretpy.cmdecorators import UpperCase, SaveSpaces, NoSpaces
from secretpy import alphabets
cipher = Autokey()
key = "test"
msg = "this is a secret message"
cm = SaveSpaces(NoSpaces(CryptMachine(cipher, key)))
out = cm.encrypt(msg)
print(out)
This returns encrypted message with spaces:
mlal bz i kmurwx ovwlmkw
This should work, but it doesn't for some reason... Shouldn't the autokey "key" be a string instead of an integer? It's documented as an integer.