o >d@sHdZddZddZddZddZd d Zd d Zd dZddZdS)z A file of secret functions. You weren't able to see this code during the lab, but you had to figure out what was happening using the debugger. cCs||S)zAdds two things together.)xyrrJ/home/pmwh/teaching/111/cs111-site/content/labs/lab09/solutions/secrets.pyasrcCs |}d|ddddS)zScrambles up a string. Nz )splitjoin)rpartsrrrb sr cC`t|t|kr|d}t|t|ksd}tt|D]}||}||}|t||7}q|S)z0Encrypts or decrypts a message using a password.)lenrangecryptrrresulticprrrrrcCr )z$Decrypts a message using a password.r r)rrdecryptrrrrd#rrcCst|}d|tdkrdkrnn|tdSd|tdkr(dkr2nnd|tdSd|tdkr@dkrJnnd|tdS|dkrPd S|d krVd Sd S) z%Returns number from alphabetic value.rA0 4 >r?N)ord)rorrran4s    r%cCs`|dkrdS|dkr dS|dkrttd|S|dkr&ttd|dSttd |dS) zReturns letter.r"rr!r rrrrr)chrr#)nrrrnaEsr(cCs8t|}t|}|dus|dur|S||d}t|S)z!Encrypts letter a using letter b.N@r%r(rr Zn1Zn2rrrrrS  rcCs8t|}t|}|dus|dur|S||d}t|S)z!Decrypts letter a using letter b.Nr)r*r+rrrr]r,rN) __doc__rr rrr%r(rrrrrrs