We help IT Professionals succeed at work.

Help on using PyGenere.py's functions

Last Modified: 2012-05-09
Dear all,

Currently I am trying to use this class, PyGenere.py found here and my main aim is to produce an GUI program which is very similar to the website given earlier with few improvements such as selecting text files on keywords, encrypted text and freq. distribution for each language.

For now, I need some help on using the methods found in PyGenere.py class.

I been trying to figure out on using it.. Here are the codes that I written..
from pygenere import *

plaintext = 'Attack from dawn.'
key = 'king10'
ciphertext = Vigenere(plaintext).encipher(key)
print "Actual text as followed. " + plaintext
print "Encrypted test using key word: king10 as followed. " + ciphertext
print "Decrypted text as followed. " + Vigenere(ciphertext).decipher(key)

print "Using VigCrack to display keyword: " + VigCrack(ciphertext).crack_codeword()
print "Showing the actual message: " + VigCrack(ciphertext).crack_message()

Open in new window

Here is the output..
Actual text as followed. Attack from dawn.
Encrypted test using key word: king10 as followed. Kbgggn pzbs hdgv.
Decrypted text as followed: Attack from dawn.
Using VigCrack to display keyword: ZBSNO
Showing the actual message: Laotso ohoe icoi.

And you can see the last two results is not what I expected.
It is supposed to be..
Using VigCrack to display keyword: king10
Showing the actual message: Attack from dawn.

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


Hi gelonida,

I did tried using "*5" as recommended by the owner.
[code]ciphertext = Vigenere(plaintext*5).encipher(key)[/code]
and it gave me this..

Actual text as followed. Attack from dawn.
Encrypted test using key word: king10 as followed. Kbgggn pzbs hdgv.Nzxdms sxsp nijt.Kwdipq juyu qgaq.Kbgggn pzbs hdgv.Nzxdms sxsp nijt.
Decrypted text as followed. Attack from dawn.Attack from dawn.Attack from dawn.Attack from dawn.Attack from dawn.
Using VigCrack to display keyword: HFZXN
Showing the actual message: Dwhjtg kaef ayhy.Assepf lsts abeu.Njwdqt wntv tttl.Letzbo smun igto.Iaaqfn tafi ijmg.

you can see the last two results... It does not give me what I want.. Now I am trying to understand it and hopefully solve it so I can proceed with my GUI design..



Hi all,

It seems that by chance I place an whole paragraph of text into the variable and I am able to see the results that I want. Also the keyword needs to be in pure letters only.

For example:

Using VigCrack to display keyword: LEMON
Showing the actual message: Porter (1979) described strategy as ‘‘building defenses against the competitive forces or finding positions in the industry where the forces are weakest’’ (p. 143). He also defined positioning as an action that allows a firm’s capabilities to ‘‘provide the best defense against competitive forces’’ (Porter, 1979, p. 143). In this sense, strategic positioning can be referred to as a strategic action to find the best mixture of strategies to defend a firm against the competitive forces in the industry. The competitive strategy view and the resource-based view are the two major perspectives on determinants of strategic position and firm performance (Spanos & Lioukas, 2001). The competitive strategy view, rooted in industrial organization literature, maintains an outside-in perspective where firm performance is determined primarily by environmental factors such as industry structure. In contrast, the more recent resource-based view argues that firm-specific resources and capabilities are the factors determining firm performance. In this section, we discuss the differences between the views, the role of environmental factors, and the influence of firm-specific resources in determining the strategic positioning of e-business companies.

It turns out that it needs to be more longer than "*5" hence gelonida's answer is indirectly correct.


If possible I would like to award 300 points instead

Hi Jon, no problem.

However I do not know at all how to retroactively change the 'price' of a question.
If you find how it works, then just go ahead. It would be fine with me.


Hi gelonida,

Thanks for understanding.

To admins: I have no more problems with the "keyword" issue. Make this question officially closed.

Thank you.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.