[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Homework Help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 10
Thread images: 4

File: 1476855779350.jpg (80KB, 600x802px) Image search: [Google]
1476855779350.jpg
80KB, 600x802px
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.
>>
File: 1476876167830.jpg (49KB, 640x735px) Image search: [Google]
1476876167830.jpg
49KB, 640x735px
>>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,
>>
File: 1476831634897.jpg (252KB, 922x864px) Image search: [Google]
1476831634897.jpg
252KB, 922x864px
>>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.
>>
File: 1477227729636.jpg (268KB, 1440x1682px) Image search: [Google]
1477227729636.jpg
268KB, 1440x1682px
>>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
Thread posts: 10
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.