Hill cipher in Sage
Let’s first consider how Hill cipher encryption is commonly presented in introductory texts on cryptography or even Wikipedia. Let be a invertible matrix over and let be a matrix also over . We call the encryption key and is referred to as the plaintext. The ciphertext corresponding to is given by
According to this scheme of encryption, given
Hill cipher encryption in Sage works differently from that presented above. If is the encryption matrix key and is the plaintext matrix, then the ciphertext is the matrix . Here, is still a square () matrix and is an matrix where the entries are filled from left to right, top to bottom. According to this scheme of encryption, with and as in (1) and (2), respectively, we get
Or using Sage:
sage: version() Sage Version 4.4.1, Release Date: 20100502 sage: H = HillCryptosystem(AlphabeticStrings(), 3) sage: M = Matrix(IntegerModRing(26), [[6,24,1], [13,16,10], [20,17,15]]) sage: P = H.encoding("ACT") sage: H.enciphering(M, P) QRT

3 June 2010 at 1:52 amTweets that mention Hill Cipher in Sage « mvngu  Topsy.com