<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Encryption :: CS1 course</title><link>https://robark.gitlab.io/encryption/index.html</link><description>Chapter 11 Caesar and Vigenere Cipher</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 16 Nov 2020 19:49:00 +0000</lastBuildDate><atom:link href="https://robark.gitlab.io/encryption/index.xml" rel="self" type="application/rss+xml"/><item><title>Caesar</title><link>https://robark.gitlab.io/encryption/caesar/index.html</link><pubDate>Thu, 12 Nov 2020 20:30:50 +0000</pubDate><guid>https://robark.gitlab.io/encryption/caesar/index.html</guid><description>Lesson 37: Introduction to Caesar Cipher Here is a great video about the history of Cryptography</description></item><item><title>Caesar Cipher Solution</title><link>https://robark.gitlab.io/encryption/caesar_sol/index.html</link><pubDate>Fri, 13 Nov 2020 20:24:53 +0000</pubDate><guid>https://robark.gitlab.io/encryption/caesar_sol/index.html</guid><description>Lesson 38: Caesar cipher solution with command line arguments Slow to check command line arg for e/d for every letter. Much better if we define the +/- operator as a lambda function once before looping through every letter.
import sys # python3 caesar.py e 5 secret.txt secret.enc # python3 caesar.py d 5 secret.enc secret.txt if sys.argv[1]=='e': # better performance as oper function is set only once oper = lambda a,b: a+b elif sys.argv[1]=='d': oper = lambda a,b: a-b with open(sys.argv[3],'r') as inpf: data=inpf.read() newdata='' for char in data: ''' # slow performance to check e/d for every letter in file if sys.argv[1]=='e': newchar=chr(ord(char) + int(sys.argv[2])) elif sys.argv[1]=='d': newchar=chr(ord(char) - int(sys.argv[2])) ''' a = ord(char) b = int(sys.argv[2]) #should be located before loop newchar = chr( oper(a,b) ) newdata=newdata + newchar with open(sys.argv[4],'w') as outf: outf.write(newdata) print('Finished')</description></item><item><title>Vigenere</title><link>https://robark.gitlab.io/encryption/vigenere/index.html</link><pubDate>Mon, 16 Nov 2020 19:49:00 +0000</pubDate><guid>https://robark.gitlab.io/encryption/vigenere/index.html</guid><description>Lesson 39: Vigenere Cipher Here is the follow up video about Vigenere.
Here is a great way to iterate over the password using a generator function:</description></item></channel></rss>