Avril Coghlan <[email protected]> writes:
> 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

Well, it's zero-based, actually. So A=0, B=2, ... Z=25. You can test
this as follows:

sage: A = AffineCryptosystem(AlphabeticStrings())
sage: A.enciphering(1, 0, A.encoding('abcd'))
ABCD
sage: A.enciphering(3, 0, A.encoding('abcd'))
ADGJ

As you can see, A remains unchanged when the offset is 0, whereas B (1)
becomes D (3) when multiplying by 3.

Hope that helps.

-Keshav

----
Join us in #sagemath on irc.freenode.net !

-- 
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

Reply via email to