Reversibly convert a numeric to an alpha sequence.

Sometimes, one may choose to convert a numeric value to an alpha-numeric sequence.

One way to do this is as follows:

  1. Compile a list of characters to select from, into an alphabet array ([1-9, A-z, a-z] is one suggestion, but any ASCII sequence will do.)
  2. Read a digit from the numeric
  3. Increment your counter to step through the alphabet array by that number of index positions.
  4. The alphabet character at that position becomes the first (or last, for FIFO) character in the conversion.
  5. Be sure and check your counter for exceeding the dimension of the alphabet.
  6. Repeat until every numeric digit is converted.

The result is exactly as many characters as the input.

Note: This is not a hash, and should not be used where a hash is the intended operation. It is reversible.

Advertisements

About James Johnson

I am an amateur mathematician & political theorist who enjoys (occasionally cerebral) humor.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s