Barry Warsaw | 5e056bb | 1996-12-23 23:39:42 +0000 | [diff] [blame] | 1 | import rotor |
2 | |||||
3 | r = rotor.newrotor("you'll never guess this") | ||||
4 | r = rotor.newrotor("you'll never guess this", 12) | ||||
5 | |||||
6 | A = 'spam and eggs' | ||||
7 | B = 'cheese shop' | ||||
8 | |||||
9 | a = r.encrypt(A) | ||||
Guido van Rossum | c4c2641 | 1997-08-14 19:55:00 +0000 | [diff] [blame] | 10 | print `a` |
Barry Warsaw | 5e056bb | 1996-12-23 23:39:42 +0000 | [diff] [blame] | 11 | b = r.encryptmore(B) |
Guido van Rossum | ce32096 | 1997-08-18 13:42:28 +0000 | [diff] [blame] | 12 | print `b` |
Barry Warsaw | 5e056bb | 1996-12-23 23:39:42 +0000 | [diff] [blame] | 13 | |
14 | A1 = r.decrypt(a) | ||||
15 | print A1 | ||||
Fred Drake | 132dce2 | 2000-12-12 23:11:42 +0000 | [diff] [blame] | 16 | if A1 != A: |
Barry Warsaw | 5e056bb | 1996-12-23 23:39:42 +0000 | [diff] [blame] | 17 | print 'decrypt failed' |
18 | |||||
19 | B1 = r.decryptmore(b) | ||||
20 | print B1 | ||||
Fred Drake | 132dce2 | 2000-12-12 23:11:42 +0000 | [diff] [blame] | 21 | if B1 != B: |
Barry Warsaw | 5e056bb | 1996-12-23 23:39:42 +0000 | [diff] [blame] | 22 | print 'decryptmore failed' |
23 | |||||
Barry Warsaw | 5afafad | 1997-01-02 20:02:44 +0000 | [diff] [blame] | 24 | try: |
25 | r.setkey() | ||||
26 | except TypeError: | ||||
27 | pass | ||||
Barry Warsaw | 5e056bb | 1996-12-23 23:39:42 +0000 | [diff] [blame] | 28 | r.setkey('you guessed it!') |