SharedClassical.sagewsOpen in CoCalc
# instantiate shift cryptosystem object
S = ShiftCryptosystem(AlphabeticStrings()); S
# get my text ready for enciphering by removing spaces/commas,etc.
s = """ this is a very
long string if I had the
energy to type more and more ..."""
P = S.encoding(s)
P
key = 1
# actually encode the text
C = S.enciphering(key, P);
C
PP = S.deciphering(key, C)
PP

# a = 0, (a + k) mod 26
a = 0
k = 10;
y = mod(a+k, 26)
# this is the encoded letter "a"
y


Shift cryptosystem on Free alphabetic string monoid on A-Z THISISAVERYLONGSTRINGIFIHADTHEENERGYTOTYPEMOREANDMORE UIJTJTBWFSZMPOHTUSJOHJGJIBEUIFFOFSHZUPUZQFNPSFBOENPSF THISISAVERYLONGSTRINGIFIHADTHEENERGYTOTYPEMOREANDMORE 10
# computer_brands = ["Apple", "Asus", "Dell", "Samsung"]
# for i in computer_brands:
#     print "i = " + str(i)

for i in range(1, 6):
print "i = " + str(i)

i = 1 i = 2 i = 3 i = 4 i = 5
mod(40,26)

for i in range(0,26):
if gcd(i, 26) == 1:
a = inverse_mod(i, 26)
print str(i) + "*" + str(a) + " = 1 mod 26"

14 1*1 = 1 mod 26 3*9 = 1 mod 26 5*21 = 1 mod 26 7*15 = 1 mod 26 9*3 = 1 mod 26 11*19 = 1 mod 26 15*7 = 1 mod 26 17*23 = 1 mod 26 19*11 = 1 mod 26 21*5 = 1 mod 26 23*17 = 1 mod 26 25*25 = 1 mod 26