Cryptography - Sage
Cryptography - Sage
Cryptography - Sage
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
sage: S = ’This\n is\n a \n string’sage: S’This\n is\n a \n string’sage: print SThisisastringsage: T = "This\n is\n a \n string"sage: T’This\n is\n a \n string’sage: S == TTrueAs seen above, a string can contain newline characters and spaces. The two characters\, ", and ’ have special functionality, and must be typed as \\, \", and \’, respectively(not quite True). The newline string can be created directly by "\n" or carriage return"\r". Strings are like lists of characters, for which S[i] gives access to the i-th characterof string S. The member function join can be used to concatenate strings, but must beapplied to a string object! We demonstrate the use of these operators in the followingconstruction:sage: s = "But Angie, Angie, ain’t it time we said good-bye?\n"sage: t = "With no loving in our souls "sage: u = "and no money in our coats\n"sage: v = "You can’t say we’re satisfied\n\n"sage: w = "...they can’t say we never tried"sage: null = ’’sage: angie = null.join([s,t,u,v,w])sage: print angieBut Angie, Angie, ain’t it time we said good-bye?With no loving in our souls and no money in our coatsYou can’t say we’re satisfied...they can’t say we never triedand subsequently we cat deconstruct and reassemble our strings:95