Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

substitution cryptosystems: converting a key from alphabetic to numerical values #6565

Closed
sagetrac-mvngu mannequin opened this issue Jul 20, 2009 · 3 comments
Closed

Comments

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jul 20, 2009

The class SubstitutionCryptosystem accepts keys whose values are alphabetic characters. We should implement a method to allow a key
to be converted between alphabetic characters and numerical values. For example, here is what I have in mind:

sage: A = AlphabeticStrings()
sage: S = SubstitutionCryptosystem(A)
sage: key = S.random_key()
ABC
sage: S.alphabet_to_numbers(key)
012
sage: S.numbers_to_alphabet([0, 1, 2])
ABC

Generalizing from this, we can also have methods to do the following conversions:

  • from alphabetic characters to binary values and vice versa

  • from alphabetic characters to hexadecimal values and vice versa

  • from alphabetic characters to mod 26 values and vice versa

  • from alphabetic characters to ASCII values and vice versa

Component: cryptography

Keywords: substitution cryptosystem

Reviewer: Travis Scholl

Issue created by migration from https://trac.sagemath.org/ticket/6565

@sagetrac-mvngu sagetrac-mvngu mannequin added this to the sage-5.11 milestone Jul 20, 2009
@sagetrac-mvngu

This comment has been minimized.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@tscholl2
Copy link
Contributor

comment:6

I think it would be better to add some kind of conversion/coercion for string monoids instead of specifically for substitution cryptosystem strings. Also I don't believe there is an ASCII/byte value monoid. In either case, that would be a different ticket (see #9118). If someone still wants that they should open a new ticket.

This is also pretty easy to do by hand if someone wants to. For example, to take and element from an alphabetic monoid to a list of ascii values you can use this:

    sage: A = AlphabeticStrings()
    sage: a = A.encoding("THISISATURTLE")
    sage: map(lambda x: ord(str(x)),a)
    [84, 72, 73, 83, 73, 83, 65, 84, 85, 82, 84, 76, 69]

I'm going to set this as won't fix and give it positive review.

@tscholl2 tscholl2 removed this from the sage-6.4 milestone May 26, 2015
@tscholl2
Copy link
Contributor

Reviewer: Travis Scholl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants