Encypting a string

  • Thread starter Thread starter Jed Fletcher
  • Start date Start date
J

Jed Fletcher

I need to encrypt a string into a int value. For example

orig : JED888FLETCHER

Encrypted : 145123456259985

or some such. thanks in advance.
 
If by "int value" you mean a 32 bit C# integer value then what you ask
is impossible, there are far more possible strings than can be encoded
in 32 bits.

Assuming that you mean "a string of decimal digits of any length" then
just encrypt your string using one of the built in cyphers - AES for
preference in either CBC or CTR mode - and convert each byte of the
cyphertext into three decimal digits:

  0x00 -> "000"
  0x01 -> "001"
     ...
  0xFF -> "255"

Concatenate the three character strings.  The zero padding to three
characters is required to enable unambiguous decryption.

rossum

Any chance of some code on how to do this?
 
Jed Fletcher said:
I need to encrypt a string into a int value. For example

orig : JED888FLETCHER

Encrypted : 145123456259985

or some such. thanks in advance.

Is it supposed to be one-way (a hash, allows comparison of two values
without ever storing plain-text, useful for password-checking, message
authentication, things like that), or does the original string need to be
recoverable?
 
I need to encrypt a string into a int value. For example

orig : JED888FLETCHER

Encrypted : 145123456259985

or some such. thanks in advance.

Encrypt, encode or hash?

A hash is one way, so you cannot "decrypt" it.

Encoding can be as simple as changing symbols. To do this, make two
arrays of symbols in different orders, then find the symbol in one and
change to the symbol at the same location in the other. There are other
ways, of course, but that is simple down and dirty (NOTE that BASE 10
does not have enough symbols to handle 26 letters and 10 numbers).

Encryption generally will use Unicode (when a string) or HEX (when
binary), so it is not just numbers, but it is the safest if you need to
keep secrets, as it actually alters the data through an algorithm and
makes it very hard to reverse engineer, if not "impossible".

peace and grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top