You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
fromsecretpyimportAutokeyfromsecretpyimportCryptMachinefromsecretpy.cmdecoratorsimportUpperCase, SaveSpaces, NoSpacesfromsecretpyimportalphabetscipher=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:
fromsecretpyimportAutokeyfromsecretpyimportCryptMachinefromsecretpy.cmdecoratorsimportUpperCase, SaveSpaces, NoSpacesfromsecretpyimportalphabetscipher=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.
The text was updated successfully, but these errors were encountered: