Using HillCryptosystem() with more characters than the 26 capital letters from AlphabeticStrings()

Showing 1-3 of 3 messages
Using HillCryptosystem() with more characters than the 26 capital letters from AlphabeticStrings() be 9/23/12 2:18 PM
I wanted to enhance the educational Sage sample 2.16 in chapter 2.5.3 of the CrypTool Script (http://www.cryptool.org/images/ctp/documents/CrypToolScript-en.pdf)
in order to allow e.g. blanks within the text to be encrypted with the Hill cipher.
[This and other Sage samples in the CT Script were developed with the thankful help of Minh Van Nyuyen, using AlphabeticStrings() as first argument for HillCryptosystem().]

I'd like to get help how to either enhance AlphabeticStrings() or how to make HillCryptosystem() more flexible.
>>>>>> 1---------------------beg: Working Code where the blank is deleted from the plaintext P before doing the encryption:
P="PREPARE TO NEGOTIATE "
keylen=3
A=AlphabeticStrings()
H=HillCryptosystem(A, keylen);H
Hill cryptosystem on Free alphabetic string monoid on A-Z of block length 3
HKS = H.key_space()
key = HKS([[-3,-3,-4],[0,1,1],[4,3,4]]); key
[23 23 22]
[ 0  1  1]
[ 4  3  4]
msg = H.encoding(P); msg
PREPARETONEGOTIATE
sage: len(msg)
18
C = H.enciphering(key, msg); C
XKZXGISXHLJCQBVQFJ
<<<<<< 1---------------------end

>>>>>> 2---------------------beg: Code NOT working but with an idea (using an alphabet with more than 26 characters):
AS1 = AlphabeticStrings(); AS1
Free alphabetic string monoid on A-Z
AS1([ i for i in range(26) ])
ABCDEFGHIJKLMNOPQRSTUVWXYZ

AS2 = list(AS1.alphabet())+[str(x) for x in range(10)]; AS2
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
len (AS2)
36

AS3 = list(AS1.alphabet())+[str(" ")]; AS3; len (AS3)
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ']
27

keylen=3; H=HillCryptosystem(AS1, keylen);H     ### This works fine.
Hill cryptosystem on Free alphabetic string monoid on A-Z of block length 3

keylen=3; H=HillCryptosystem(AS3, keylen);H     ### This breaks!
TypeError
<<<<<< 2---------------------end

Thanks for your help.
Re: Using HillCryptosystem() with more characters than the 26 capital letters from AlphabeticStrings() kcrisman 9/24/12 5:08 AM


AS3 = list(AS1.alphabet())+[str(" ")]; AS3; len (AS3)
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ']
27

keylen=3; H=HillCryptosystem(AS1, keylen);H     ### This works fine.
Hill cryptosystem on Free alphabetic string monoid on A-Z of block length 3

keylen=3; H=HillCryptosystem(AS3, keylen);H     ### This breaks!
TypeError
<<<<<< 2---------------------end

Thanks for your help.

This sounds like a great enhancement idea, and I'm sure we can work out the breakage on a Trac ticket (knowing what the full TypeError traceback was would be a great start).  If you know Minh, then assuredly you know how to acquire a Trac account and open a new ticket.  Good luck in improving this valuable resource!
Re: [sage-support] Using HillCryptosystem() with more characters than the 26 capital letters from AlphabeticStrings() Minh Nguyen 9/29/12 12:05 AM
Hi Bernhard,

On Mon, Sep 24, 2012 at 7:18 AM, be <bernhard....@db.com> wrote:
> I'd like to get help how to either enhance AlphabeticStrings() or how to
> make HillCryptosystem() more flexible.

This is now ticket #13548:

http://trac.sagemath.org/sage_trac/ticket/13548

I have created an account for you on the Sage trac server, and have
sent the login details to you.

--
Regards,
Minh Van Nguyen
http://bit.ly/mvngu