Dear Keshav,
Thanks very much, that helps a lot and makes lots of sense now.
Using what you said, I was able to encode 'HAPPYNEWYEAR' using a 1-based
system (A=1, B=2, C=3,....Z=26) by applying (i) a multiplicative cipher
with a=1,b=1 to change to a 1-based system (ii) then a multiplicative
cipher with a=9,b=0, (iii) then a multiplicative cipher with a=1,b=25 to
change back to the 0-based system to get the answer. I did this by typing:
A = AffineCryptosystem(AlphabeticStrings())
P = A.encoding("HAPPYNEWYEAR"); P
a, b = (1, 1)
C = A.enciphering(a, b, P); C
a, b = (9, 0)
C2 = A.enciphering(a, b, C); C2
a, b = (1, 25)
C3 = A.enciphering(a, b, C2); C3
This gives 'TINNQVSYQSIF', which is what I expected.
Thanks again for your help, I appreciate it a lot.
Regards,
Avril
On Tuesday, April 17, 2012 11:50:22 AM UTC+1, Avril Coghlan wrote:
>
> Dear all,
>
> I'm trying to figure out how to make a multiplicative cipher in SAGE.
> For example, to make a multiplicative cipher:
> M_9{m} = 9 x_{26} m
> and to use it to encipher the text 'HAPPYNEWYEAR', I tried typing:
>
> A = AffineCryptosystem(AlphabeticStrings())
> P = A.encoding("HAPPYNEWYEAR"); P
> a, b = (9, 0)
> C = A.enciphering(a, b, P); C
>
> I get back:
> LAFFINKQIKAX
>
> However, I think I should get back:
> TINNQVSYQSIF
> assuming A=1, B=2, C=3, D=4.... Y=25, Z=26
>
> In order to get 'TINNQVSYQSIF', I have to type:
> a, b = (9, 8)
> instead of
> a, b = (9, 0)
> I am wondering why this is?
>
> I had thought:
> a, b = (9, 0)
> should give the multiplicative cipher:
> M_9{m} = 9 x_{26} m
> Is this wrong?
>
> I would be grateful for any pointers.
>
> Kind Regards,
> Avril
>
> Avril Coghlan
>
>
>
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org