;ō ._ī>c@sdZdklZdklZdklZlZlZlZdeefd„ƒYZe djoŽeƒZ e i dƒpt ‚e i dƒ pt ‚e i d ƒ pt ‚d e _ e i d jpt ‚e id ƒd jpt ‚e id ƒd jpt ‚ndS(s#This module contains the Rot class.(sCharacterCipher(s KeyedCipher(s LEN_ALPHABETsapply_caselesssoffsets from_offsetsRotcBsPtZdZdZdZd„Zd„Zd„Zd„Zd„Z d„Z RS( s¸This is the cipher used in Rot7, Rot13, Ceasar's code, etc. This is a simple cipher that simply rotates the characters by an offset. For instance, ab..z -> b..za. The following attributes are used: key - What is the offset used in the rotation? This will initially be set to defaultKey. keyDescription - This is a description of what constitutes a valid key. defaultKey - This is the default key. san integer in the range [0, 25]icCs|i|_dS(sSet key to defaultKey.N(sselfs defaultKeyskey(sself((s./cipher/Rot.pys__init__scCs|i||iƒSdS(sEncrypt and return c.N(sselfs_encryptCharacterscskey(sselfsc((s./cipher/Rot.pysencryptCharacter!scCs|i||i ƒSdS(sDecrypt and return c.N(sselfs_encryptCharacterscskey(sselfsc((s./cipher/Rot.pysdecryptCharacter%scs-|iƒ o|Snt‡d†|ƒSdS(s)Encrypt and return c. Use the given key.cstt|ƒˆtƒS(N(s from_offsetsoffsetscskeys LEN_ALPHABET(sc(skey(s./cipher/Rot.pys.sN(scsisalphasapply_caseless(sselfscskey((skeys./cipher/Rot.pys_encryptCharacter)scCs1t|tdƒƒod|jo |tjSdS(s*Is key a a valid key? See keyDescription.iN(s isinstanceskeystypes LEN_ALPHABET(sselfskey((s./cipher/Rot.pys isValidKey0scCsa|}|djo7yt|ƒ}WqJtj o|i|ƒqJXnti|||ƒdS(s9Extend KeyedCipher.__setattr__ to cast the key to an int.skeyN( svaluesstrvalues attributesints ValueErrorsselfsraiseInvalidKeys KeyedCiphers __setattr__(sselfs attributesvaluesstrvalue((s./cipher/Rot.pys __setattr__4s ( s__name__s __module__s__doc__skeyDescriptions defaultKeys__init__sencryptCharactersdecryptCharacters_encryptCharacters isValidKeys __setattr__(((s./cipher/Rot.pysRots      s__main__ii˙˙˙˙sas1isaAzZsbBaAN(s__doc__sCharacterCiphers KeyedCiphersToolss LEN_ALPHABETsapply_caselesssoffsets from_offsetsRots__name__sciphers isValidKeysAssertionErrorskeysencryptsdecrypt(sapply_caselesss KeyedCiphersciphers LEN_ALPHABETsoffsetsCharacterCiphersRots from_offset((s./cipher/Rot.pys?s  8