Hello I'm using a javascript RSA encryption process and it's working :
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="base64.js"></script>
<script type="text/javascript" src="asn1.js"></script>
<script type="text/javascript" src="jsbn.js"></script>
<script type="text/javascript" src="prng4.js"></script>
<script type="text/javascript" src="rng.js"></script>
<script type="text/javascript" src="rsa.js"></script>
<script type="text/javascript" src="pemconvert.js"></script>
<script>
function loadpubKey(){
var pubkey = "-----BEGIN PUBLIC KEY-----\nMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPBYvSszUjI5psKM958bHTDb+9NONv3X\nWVIGLR9/Al4j8/mqSDMhwFuu9oEyXl80+Ga2cohEQPpWyxzg3/tfGDUCAwEAAQ==\n-----END PUBLIC KEY-----";
$("#publicKey").html(pubkey);
}
function RSAEncryptData()
{
var Message = $("#Message_to_Encrypt").val();
var pubkey = pem_import($("#publicKey").val());
$("#RSAMessageEncrypted").html(pubkey.encrypt(Message));
}
</script>
</head>
<body onload="loadpubKey();">
<h1>RSA Encryption/Decryption using library From :https://github.com/tao-software/jsrsa</h1>
<form>
<strong>Public key :</strong> <textarea rows="3" cols="100" id="publicKey"></textarea><br>
<strong>Message to RSA encrypt :</strong> <textarea rows="3" cols="100" id="Message_to_Encrypt"></textarea><br>
<input type="button" value="RSA Encrypt" onclick="RSAEncryptData();">
<strong>RSA encrypted Message :</strong> <textarea rows="3" cols="100" id="RSAMessageEncrypted"></textarea><br>
</form>
</body>
</html>
Each time I hit "encrypt" button using the same message to encrypt I get a new different encrypted value. What can I do to make this encryption giving the same encrypted result for the same message used?
Actually what I want to do is to encrypt some phone numbers with a public key using RSA then store them in a table after that I will encrypt any phone number that I'll get through a process with the same public key in RSA and look in the table if there is a match.
With the script above I will never find a match even if I'm encrypting the same phone number more than once that's why I want the result to be the same when encrypting the same phone number. Any idea is welcome.
Thank you in advance.