Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8938

Re: Simple alphanumeric "encryption"?

From "Qu0ll" <Qu0llSixFour@gmail.com>
Newsgroups comp.lang.java.programmer
References <S8idnWT1OekbSwbTnZ2dnUVZ_q-dnZ2d@westnet.com.au> <alpine.DEB.2.00.1110171515220.10855@urchin.earth.li>
Subject Re: Simple alphanumeric "encryption"?
Date 2011-10-18 14:18 +1100
Message-ID <pIKdnalVhP-ubQHTnZ2dnUVZ_hCdnZ2d@westnet.com.au> (permalink)

Show all headers | View raw


"Tom Anderson"  wrote in message 
news:alpine.DEB.2.00.1110171515220.10855@urchin.earth.li...

Sorry about the lack of indent...

------------------------------------------------------------------------------------------------
Oddly, i have a paper called "Ciphers with Arbitrary Finite Domains"
sitting in my reading queue right not.

You have at least two basic routes of attack here.

First, recognise that alphanumerism is just an encoding of a general bit
string. Decode the alphanumeric string into a bit string (by taking it as
a base-36 or base-62 number, or whatever), encrypt that, then re-encode
it. BigInteger has a constructor which takes a string and a radix, and a
toString method which takes a radix. So:

String s = "1sxjxyr5owpxwzmax6pyv1wgjpfuc4iadgrzhjpcameipq5sk";
BigInteger i = new BigInteger(s, 36);
i = i.multiply(BigInteger.valueOf(2)); // this is a very poor kind of 
encryption
System.out.println(i.toString(36));

BigInteger can also be converted to and from a byte[], which you can
subject to proper encryption. You will need to be a bit careful, because
conversion to an alphanumeric string will remove any leading zeroes, so
you may need to pad. Also, the numbers may be negative, in which case the
alphanumeric strings will have a leading minus sign. You might prefer to
write your own conversion between bytes and digits, to avoid these
problems.

Note that using a proper cipher involves generating an initialisation
vector (IV) for each message you encrypt, which you will then need to send
along with the ciphertext. That's going to be slightly annoying, since the
alphanumerically encoded IV is likely to be just as long as your message.

Second, come up with a cipher that works directly on alphanumeric values,
rather than bit strings, and apply that to your string. I don't think this
is actually a terribly good idea, so i won't elaborate on it.

------------------------------------------------------------------------------------------------

OK, thanks Tom for that - the first option looks promising.

I have 2 questions:

Is there any significance in the choice of numbers 36 and 62?

Can this simple method be adapted to handle input strings that contain 
spaces and also to preserve the case of the inputted characters?  I forgot 
to mention this.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@gmail.com
[Replace the "SixFour" with numbers to email me] 

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Simple alphanumeric "encryption"? "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-17 18:16 +1100
  Re: Simple alphanumeric "encryption"? Arne Vajhøj <arne@vajhoej.dk> - 2011-10-17 08:13 -0400
    Re: Simple alphanumeric "encryption"? Travers Naran <tnaran@gmail.com> - 2011-10-18 06:47 -0700
      Re: Simple alphanumeric "encryption"? David Segall <david@address.invalid> - 2011-10-20 00:36 +1100
  Re: Simple alphanumeric "encryption"? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-10-17 12:27 +0000
  Re: Simple alphanumeric "encryption"? Tom Anderson <twic@urchin.earth.li> - 2011-10-17 16:45 +0100
    Re: Simple alphanumeric "encryption"? "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-18 14:18 +1100
      Re: Simple alphanumeric "encryption"? "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-18 14:25 +1100
      Re: Simple alphanumeric "encryption"? Lew <lewbloch@gmail.com> - 2011-10-18 08:43 -0700
      Re: Simple alphanumeric "encryption"? Tom Anderson <twic@urchin.earth.li> - 2011-10-20 20:57 +0100
  Re: Simple alphanumeric "encryption"? B1ll Gat3s <wm.g4t3s@m1cr0s0f7.c0m> - 2011-10-17 21:33 -0400
  Re: Simple alphanumeric "encryption"? Roedy Green <see_website@mindprod.com.invalid> - 2011-10-20 13:32 -0700
  Re: Simple alphanumeric "encryption"? Roedy Green <see_website@mindprod.com.invalid> - 2011-10-20 13:36 -0700

csiph-web