How to decrypt a crypto encrypted string

I want to encrypt a password that is saved on the device.

I’m trying:[lua]require “crypto”
print (crypto.hmac( crypto.md5, “key”, “test” )) --> 171d80f9cebec0767287d2eb2e4b2abc[/lua]

That part works great but how do I get the string “test” back from the encryption?

TIA [import]uid: 6547 topic_id: 9753 reply_id: 309753[/import]

MD5 is a one-way cryptographic hash algorithm, you aren’t supposed to be able to get the original chars back: http://en.wikipedia.org/wiki/One-way_function [import]uid: 4596 topic_id: 9753 reply_id: 35564[/import]

Thanks singh206.

Of course the purpose of such a one-way function is beyond me so I won’t worry about it :slight_smile:

Have decided not to encrypt anyways.
One less item to possibly trip over at the app store. [import]uid: 6547 topic_id: 9753 reply_id: 35584[/import]

It’s commonly used to store sensitive info in databases, like passwords. If an unauthorized person gains access to the database they won’t acquire the actual passwords, only the encrypted hash you’ve stored. It’s also used for verifying the integrity of file content. A hash of [myfile]sometext[/myfile] can prove that a hacker didn’t tamper with it because the hash of the original and [myfile]sometaintedtext[/myfile] are different.

Depending on your need, you could explore writing your own obfuscation library. I’m pretty sure there are 2 way encryption libs, mcrypt or SHA1? But I’ve never used a 2 way myself. [import]uid: 4596 topic_id: 9753 reply_id: 35593[/import]

So if you do one way encryption. Are you actually comparing user input hash to the hash stored in database? I’m new to here and trying to learn. Thanks. -Edwin

So if you do one way encryption. Are you actually comparing user input hash to the hash stored in database? I’m new to here and trying to learn. Thanks. -Edwin