I need a code based on this attack on hill cipher

http://practicalcryptography.com/cryptanalysis/stochastic-searching/cryptanalysis-hill-cipher/

in python. As I am not maths student I am so helpless in this. Also I need to specify the charecterset of my own here.. can anyone help?

Here is a math 'black box' that you can use

from nzmath.gcd import extgcd
from nzmath.matrix import Matrix

def decrypt_key(cyph, uncyph, nletter):
    A = Matrix(2, 2, list(cyph))
    D = A.determinant()
    u, v, d = extgcd(D, nletter)
    if d != 1:
        raise RuntimeError("Can not compute key matrix")
    B = (Matrix(2, 2, list(uncyph)) * A.adjugateMatrix() * u) % nletter
    x, y = B.compo
    return tuple(x + y)

if __name__ == '__main__':
    print(decrypt_key((15, 12, 2, 19), (5, 7, 19, 4), 26))

"""my output -->
(3L, 19L, 15L, 14L)
"""

install module nzmath from pypi.

hi mod i am not able to chat with u as i m new can u pls tell whr we can chat like gtalk or skype
i have still queries in it
i have with me encrypted text as well as charset but i dont got the key
also my matrix is 3x3

Please avoid SMS language in the forum ...

The best thing to do is to post your attempts to decipher your text with python in this thread. We may be able to help you but nobody will write the code for you.

Oops!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.