3

I need to transmit some data over the wire and I don't want that data being plain text.

The text I'm sending needs to be reversed so I can't md5/sha256/etc...

What's a good way to encode a salted string?

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
dave
  • 7,717
  • 19
  • 68
  • 100

3 Answers3

5

You're looking for encryption.

What language are you using? You probably have a built-in encryption algorithm you can use.


The idea with hashing is that you can only go one-way.

[plain text]--->(HASH ALGORITHM)--->[hash]

Whereas the idea with encryption is that you can use a key together with some plaintext to create a ciphertext. Then you can use the key on the ciphertext to retrieve the plaintext at any time:

[plain text] + [key] --->(ENCRYPTION ALGORITHM)-->[ciphertext]
[ciphertext] + [key] --->(DECRYPTION ALGORITHM)-->[plain text]

The decryption algorithm for a given encryption algorithm is usually very similar to the encryption algorithm, and it allows for the retrieval of a plaintext message given a ciphertext and the correct key (ie password).

Cam
  • 14,930
  • 16
  • 77
  • 128
  • Gonna use PHP to whip up the small API – dave Apr 08 '10 at 01:52
  • In particular check this out: http://www.php.net/manual/en/mcrypt.ciphers.php -->above, someone recommended AES. Take a look at MCRYPT_RIJNDAEL_128, it's basically the same thing. – Cam Apr 08 '10 at 01:58
3

You want to use an encryption function, not a hash - which by definition is one-way.

The AES encryption algorithm would be a good start, as the is probably the most widely used one at present.

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
0

You don't want a hash, you want encryption. You should look at Blowfish.

Tor Valamo
  • 33,261
  • 11
  • 73
  • 81