11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

sage: I = [7, 4, 11, 11, 14, 22, 14, 17, 11, 3]sage: hello = S(’’)sage: for i in I:....: hello *= S.gen(i)....:sage: helloHELLOWORLDAlternatively we can either recognize a Python string in the given string monoid:sage: S(’ABC’)ABCsage: H(’0a91’)0a91sage: B(’0110’)0110or use standard encodings to map ASCII strings to the monoid:sage: S.encoding(’abc’)ABCsage: H.encoding(’abc’)616263sage: B.encoding(’abc’)011000010110001001100011Note that the first construction gives a non-injective map from ASCII strings to uppercase (stripping away non-alphabetic characters by mapping them to the empty string).The latter two give the hexadecimal and binary encodings of the underlying ASCII bytesfor the characters. These altter are injective maps:sage: S.encoding(’abc’).decoding()ABCsage: H.encoding(’abc’).decoding()abcsage: B.encoding(’abc’).decoding()abc98 Appendix B. SAGE Cryptosystems

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

Saved successfully!

Ooh no, something went wrong!