Hi All,
I would like to encrypt password string in Corona as following (We can encrypt a string in php like this),
function encrypt($sData, $secretKey){
$sResult = ‘’;
for($i=0;$i<strlen($sData);$i++){
$sChar = substr($sData, $i, 1);
$sKeyChar = substr($secretKey, ($i % strlen($secretKey)) - 1, 1);
$sChar = chr(ord($sChar) + ord($sKeyChar));
$sResult .= $sChar;
}
return encode_base64($sResult);
}
chr() - Returns a one-character string containing the character specified by ascii.
ord() - Returns the ASCII value of the first character of string
http://www.asciitable.com/
base64_encode() - Encodes the given data with base64.
I am sure Corona can do substring-> string.sub() and string length -> string.len().
Wonder
if Corona has functions that does the same thing for -> chr() ->
string.char() , ord() -> string.byte(), base64_encode()
My First Question is: Is it possible to encrypt a String(Password) in Corona SDK?.I found only Hashing and Message Digest in Corona SDK.I didn’t find “Encryption/Decryption” in Corona SDK. (If we cannot encrypt a string in Corona SDK,how to encrypt my password string?
My Second Question is: Is it possible to encrypt a String like the above PHP code?
Please help me…I don’t find any way to do it in Internet…
Best Regards,
John