Opened 12 years ago
Closed 12 years ago
#1840 closed enhancement (fixed)
[with bundle, positive review] Hill cipher addition to crypto package
Reported by: | kohel | Owned by: | cwitty |
---|---|---|---|
Priority: | minor | Milestone: | sage-2.10.1 |
Component: | misc | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
This adds functionality for Hill ciphers as in the following example:
sage: S = AlphabeticStrings() sage: E = HillCryptosystem(S,7) sage: E.random_key() [13 1 23 4 14 15 0] [11 4 4 12 0 23 14] [18 4 25 13 10 7 10] [ 9 14 13 11 1 12 10] [13 8 10 19 24 13 24] [ 8 7 12 12 25 2 10] [ 2 7 1 10 13 12 5] sage: e = E(E.random_key()) sage: e [ 1 9 8 17 16 2 13] [11 12 12 24 12 25 2] [18 21 20 2 16 7 17] [17 17 8 19 14 23 19] [15 11 24 6 5 7 4] [17 20 18 6 16 13 13] [ 2 12 17 4 23 4 4] sage: pt = S([ randint(0,25) for i in range(7*16) ]) sage: pt QWTWCUQMBMTGDSGTHNJLBNDEXYWGJKHZGAPRFKMPGJDXDLYYGZVTXHLJIMOGKERMWCMOOJKHGCTXAOVIJCXBIGRSLVCBZAXJBCDAEHUZUGCEYCLA sage: e(pt) YBQWKZZLXQLKVACTPHEFPHAWYSSUKFVQJGJVGVNYWXDRYMYHXZIBOGJISSTQTOQYQPYNKIVPAQZNJDXJRNPKQUWYRRGRLGERSLXUAWAMXXGSQETD sage: c = e.inverse() sage: c(e(pt)) == pt True sage: e.key() [ 1 9 8 17 16 2 13] [11 12 12 24 12 25 2] [18 21 20 2 16 7 17] [17 17 8 19 14 23 19] [15 11 24 6 5 7 4] [17 20 18 6 16 13 13] [ 2 12 17 4 23 4 4] sage: type(e.key()) <type 'sage.matrix.matrix_modn_dense.Matrix_modn_dense'> sage: type(e) <class 'sage.crypto.classical_cipher.HillCipher'> sage: A = e.key() sage: A.det() 17
Attachments (2)
Change History (7)
Changed 12 years ago by
comment:1 Changed 12 years ago by
- Summary changed from Hill cipher addition to crypto package to [with bundle, needs review] Hill cipher addition to crypto package
comment:2 Changed 12 years ago by
- Description modified (diff)
comment:3 Changed 12 years ago by
- Summary changed from [with bundle, needs review] Hill cipher addition to crypto package to [with bundle, mostly positive review] Hill cipher addition to crypto package
Changed 12 years ago by
comment:4 Changed 12 years ago by
- Summary changed from [with bundle, mostly positive review] Hill cipher addition to crypto package to [with bundle, positive review] Hill cipher addition to crypto package
Works for me, and I posted a second patch changing repr's to _repr_.
comment:5 Changed 12 years ago by
- Resolution set to fixed
- Status changed from new to closed
Merged in Sage 2.10.1.alpha1
Note: See
TracTickets for help on using
tickets.
Patch looks good and applies cleanly against 2.10. Only detail: It uses
__repr__
rather than_repr_
(two instead of one underscore) but inherits fromSageObject
. All objects inheriting fromSageObject
are supposed to implement_repr_
.