11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CryptosystemsSpecific cryptosystem can be created in SAGE with the following commands:sage: S = AlphabeticStrings()sage: SFree alphabetic string monoid on A-Zsage: E = SubstitutionCryptosystem(S)sage: T = TranspositionCryptosystem(S,15)sage: TTransposition cryptosystem on Free alphabetic string monoid on A-Zof block length 15The latter constructor (of the transposition cryptosystem) specifies a key length of 15characters. The SAGE cryptosystem represents a ...sage: K = E.random_key()sage: KHYTIKQRWXUPZBJSCANEFODLVMG # randomsage: K = S(’HYTIKQRWXUPZBJSCANEFODLVMG’)sage: e = E(K)sage: eHYTIKQRWXUPZBJSCANEFODLVMGsage: e(S(’THECATINTHEHAT’))FWKTHFXJFWKWHFsage: m = E.encoding("This is sample message text to be encoded.")sage: mTHISISSAMPLEMESSAGETEXTTOBEENCODEDsage: c = e(m)sage: cFWXEXEEHBCZKBKEEHRKFKVFFSYKKJTSIKIsage: L = E.inverse_key(K)sage: E.enciphering(L,c)THISISSAMPLEMESSAGETEXTTOBEENCODEDsage: E.deciphering(K,c)THISISSAMPLEMESSAGETEXTTOBEENCODED99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!