Can someone help me with my homework and write a Vigenere cipher in Python - nothing from google, those sources don't help me
Only alphabetical characters , plz help
>>57238909
>Vigenere cipher in Python
http://programeveryday.com/post/implementing-a-basic-vigenere-cipher-in-python/from itertools import cycle
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
def encrypt(key, plaintext):
"""Encrypt the string and return the ciphertext"""
pairs = zip(plaintext, cycle(key))
result = ''
for pair in pairs:
total = reduce(lambda x, y: ALPHA.index(x) + ALPHA.index(y), pair)
result += ALPHA[total % 26]
return result.lower()
def decrypt(key, ciphertext):
"""Decrypt the string and return the plaintext"""
pairs = zip(ciphertext, cycle(key))
result = ''
for pair in pairs:
total = reduce(lambda x, y: ALPHA.index(x) - ALPHA.index(y), pair)
result += ALPHA[total % 26]
return result
def show_result(plaintext, key):
"""Generate a resulting cipher with elements shown"""
encrypted = encrypt(key, plaintext)
decrypted = decrypt(key, encrypted)
print 'Key: %s' % key
print 'Plaintext: %s' % plaintext
print 'Encrytped: %s' % encrypted
print 'Decrytped: %s' % decrypted
Now that was HARD.
Daily reminder that homeworks will get harder.
In a sense that someday you won't be able to google the right answer.
And if you don't learn some stuff, you will be screwed.
>>57238978
I know man, but he only taught us for loops, while loops, if else statements, mathematical operators, and boolean expressions, then just shoved this on us -
like we could somehow put it altogether without any lessons on code design and such....
>>57239081
Then there's a way to do it with only the information that you've been thaught
I think this is a honeypot thread. The wiki is weird. As in,
>>57239100
But How? And I can't use >>57238978 because it includes lambda and reduce, which he hasn't taught us and doesn't want us using...
>>57239171
What's a honeypot thread?
>>57239081
I hate to be that guy who crushes your ideals and basically starts end of your "childhood", but
>there were times when nothing like internet existed
>all you had was "recommended book list"
>and bunch of tasks to do to pass yet another semester / grade / tutorial / whatever
Now you live in an era where almost all knowledge is few clicks away, the only barrier is your
>language
>patience
>time
>sometimes payment
Being programmer / code monkey / software engineer / mathematician / almost any "STEM" field is mainly about being able to
>find information
>understand information
>apply information
and since we live in capitalism
>sell yourself in market / boss meeting usually by very stupid colorful presentation
Very rarely you will have to solve NEW UNIQUE problems. Enjoy your study before you will start solving repetitive boring stuff. Like me, who solved bonus task which was simple implementation of
calculating mathematical expressions (+-*/()). Boy that was hard, because finite state machine and
syntax and grammar was taught year later.
>>57239208
You can do it OP, I believe in you.
Have you tried reading that page? What about reading each line of code and realizing what does that do and more importantly WHY?
You can do it.
>>57239208
A honeypot is something college professor's use at the behest of military personnel. It helps them tie down people to certain kinds of crimes. It also helps with creating plot in the narrative. If that makes no sense to you or scares you don't learn about computer security.
>>57239262
You know what? You're right! I CAN do this! I'm signing off for now! :D
>>57239081
>like we could somehow put it altogether without any lessons on code design and such....
wow you poor thing life is so hard you spoiled fucking bitch