Code Monkey home page Code Monkey logo

pycipher's People

Contributors

bradleyayers avatar jameslyons avatar ninniuz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycipher's Issues

Push to pypi

Would it be possible to push a stable release to pypi?

Playfair issue when decoding

When I try to decode a playfair cipher, it tells me: 'ValueError: '__' is not in list' after attempting to run this line: arow, acol = int(self.key.index(a) / 5), self.key.index(a) % 5.

The '__' is whatever the first letter of the ciphertext is. I've tried several different texts and it always gives me that error. Is this user error?

Ciphers using a 5x5 keysquare can't encipher messages containing 'j'

If I use a cipher that requires a 5x5 keysquare with 'j' omitted, I can't encipher a message that includes the letter 'j'.

Test case:

>>> from pycipher import ADFGX
>>> ADFGX('phqgmeaylnofdxkrcvszwbuti','HELLO').decipher('bluejay')    
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/.../lib/python3.6/site-packages/pycipher/adfgx.py", line 52, in decipher
    step1 = PolybiusSquare(self.key,size=5,chars='ADFGX').decipher(step2)
  File "/Users/.../lib/python3.6/site-packages/pycipher/polybius.py", line 65, in decipher
    ret += self.decipher_pair(string[i:i+2])
  File "/Users/.../lib/python3.6/site-packages/pycipher/polybius.py", line 32, in decipher_pair
    row = self.chars.index(pair[0])
ValueError: substring not found

pycipher not working under Python 3.12

When trying to run a program using pycipher under Python 3.12 in VS Code I get a ModuleNotFoundError: No module named 'pycipher' error. Changing to Python 3.8 works fine.

Enigma M3 Cipher

Is the cipher broken? I can't get a decode on other sites using James' code.

This is the code I wrote to try the module:

https://paste.pydis.com/serazawora.py

This is my output using random rings etc:

Your deciphered text: JYPVNHK
Your first rotor: 6
Your second rotor: 6
Your third rotor: 7
Your first position: 9 / I
Your second position: 22 / V
Your third position: 8 / H
Your first ring: 26 / Z
Your second ring: 6 / F
Your third ring: 17 / Q
Your reflector: B
Your plugboard: [('h', 'p'), ('m', 'g'), ('w', 'f'), ('y', 't'), ('v', 'i'), ('o', 'r'), ('u', 'k'), ('q', 'z'), ('b', 's'), ('l', 'a')]

Now I used Cryptii to decode and got this when I input those stuff above: http://i63.tinypic.com/2ivxvnr.png

Not sure if I am doing something wrong or the module's code is broken

ADFGVX cipher doesnt support digits

it doesn't encrypted or decrypted digits so it actually an ADFGX cipher.

i've tried everything to get it to work but i cant. any help would be appreciated.

thank you

Bug In foursquare.py, Line 27

>>> from pycipher import Foursquare
>>> ciphertext = Foursquare(key1='zgptfoihmuwdrcnykeqaxvsbl',key2='mfnbdcrhsaxyogvituewlqzkp').encipher('Hello World!')  
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/linuxuser/.local/lib/python3.9/site-packages/pycipher/foursquare.py", line 49, in encipher
    a,b = self.encipher_pair(string[c],string[c+1])
  File "/home/linuxuser/.local/lib/python3.9/site-packages/pycipher/foursquare.py", line 27, in encipher_pair
    return (self.key1[arow*5+bcol], self.key2[brow*5+acol])
TypeError: list indices must be integers or slices, not float

ADFGVX ignores numbers

Testcase:

In [1]: from pycipher import ADFGVX

In [2]: ADFGVX().encipher('1')                                                                                                                                                                            
Out[2]: ''

I would expect the ciphertext to not be empty, as ADFGVX supports numbers.

I believe the issue was introduced here and here. Without the filter argument, remove_punctuation filters out any numbers.

Playfair encrypt error encoding "BAAAH

We discovered that the encipher method of Playfair does not encrypt BAAAH correctly when using the key "KINGSABCDEFHLMOPQRTUVWXYZ". It returns "CBCVLW" when it should be "CBVCLW". However if I write the grid out:

KINGS
ABCDE
FHLMO
PQRTU
VWXYZ

BAAAH -> BAXAH -> BAXAHX -> CBVCLW

How to crack enigma messages?

@jameslyons
Hi James!

From what I understand you're the author of:
http://practicalcryptography.com/cryptanalysis/breaking-machine-ciphers/cryptanalysis-enigma/

In the article you say you have python code for this cracker, but I can't find anywhere.

I have python code as well, but it takes significantly longer to run (~30 min). If anyone really wants it I may post it.

So this brings up a few questions,

  1. Do you actually have a python ported version of the C-code from that article (or like it)?

  2. The article is 10 years old, so python should be able to handle this very quickly now?

  3. There is also the MCMC method with Jupyter here for breaking Enigma. Is this feasible, for a general cracker?
    [*Yeah, sure there are probably better texts for statistics than using Marvel comics!]

  4. Then there is the NSA (?) Enigma simulator "cracker" notebook here, but i am not able to evaluate the usefulness of this.
    Can it do the job?

  5. What are the limitations on the massage lengths needed in order to be cracked?

Any useful insights or suggestions would be much appreciated.

Caesar changes string to uppercase

Hi James
I am using the Caesar cipher to encrypt my text string, which consists of lower and upper case. But, the Caesar method changes it to all upper case. And, when I decrypt it is all upper case, which won't match my original mixed case string. Any suggestions appreciated.

code snippet:
USERNAME = os.environ['NETWORK_USERNAME']
PASSWORD = os.environ['NETWORK_PASSWORD']
from pycipher import Caesar
var1 = Caesar(key=21).encipher(USERNAME,keep_punct=True)
print(var1)
var2 = Caesar(key=21).encipher(PASSWORD,keep_punct=True)
print(var2)

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.