Giter VIP home page Giter VIP logo

secretpy's Issues

Error when i using affine cipher

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)

Non-existing character in an alphabet

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.

can only concatenate str (not "bytes") to str

plaintext = u"string"

Works fine

Problem

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)

Error

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

Error when using a space in vigenere cipher

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!

Autokey broken?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.