tigertv / secretpy Goto Github PK
View Code? Open in Web Editor NEWClassical ciphers: Caesar, ADFGX, ROT13 and etc.
Home Page: https://pypi.org/project/secretpy/
License: MIT License
Classical ciphers: Caesar, ADFGX, ROT13 and etc.
Home Page: https://pypi.org/project/secretpy/
License: MIT License
File "D:\Myprojects\TestEncryptions\test.py", line 101, in affine_encrypt
return Affine().encrypt('cool','12')
File "D:\Myprojects\TestEncryptions\secretpy\ciphers\affine.py", line 26, in encrypt
subst = {c: alphabet[(i * a + b) % len(alphabet)][0] for i, letters in enumerate(alphabet) for c in letters}
File "D:\Myprojects\TestEncryptions\secretpy\ciphers\affine.py", line 26, in
subst = {c: alphabet[(i * a + b) % len(alphabet)][0] for i, letters in enumerate(alphabet) for c in letters}
TypeError: not all arguments converted during string formatting
I tried affine cipher. Python 3.10.2
Text: cool
Key: "12" (str)
Conclusions from #2:
Handle exceptions when a character doesn't exist in an alphabet.
A solution would be either to show an error message or remove non-existing characters from message.
People want it.
plaintext = u"string"
Works fine
What if we have to ask plaintext from user, how can we unicode it now.
Python 3.x does not support unicode() function
My Code
cipher = secretpy.Vigenere()
string = input("Enter Plaintext")
key = input("Enter Key")
def encrypt_vigenere(string,key):
encrypted_string = cipher.encrypt(string,key)
return encrypted_string
encrypt_vigenere(string,key)
File "/usr/local/lib/python3.8/dist-packages/secretpy/ciphers/vigenere.py", line 43, in encrypt
return self.__encDec(alphabet, key, text, 1)
File "/usr/local/lib/python3.8/dist-packages/secretpy/ciphers/vigenere.py", line 19, in __encDec
raise Exception("Can't find char '" + wrchar + "' of text in alphabet!")
TypeError: can only concatenate str (not "bytes") to str
i looked through your code and its really solid, the problem is whenver my ciphertext has a space, the code raises a KeyError exception and it says 'cant find the character ' ' in alphabet!
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 = CryptMachine(cipher, key)
out = cm.encrypt(msg)
print(out)
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.