I have this html file which I am using to encrypt a string to sha1 hash. I receive the string like "1 | 2 | 3" from a javascript function (I haven't shown the function below), and I need to replace the | with - and then encrypt the modified string. Here's the code I have built so far -
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var test;
var value;
var message = "1 | 2 | 3";
test = message.split(' | ');
value = "<?php $final = test[0] . " - " . test[1] . " - " . test[2]; echo sha1($final);?>";
alert(value);
</script>
</body>
</html>
I came to know about posting the value to another PHP file using HTML form, and accessing it through $_POST
/$_GET
- but my app won't allow for 2 files; hence I am trying to combine it all in one html file...
PHP has a in-built SHA1 encryption function, but javascript doesn't - the value
variable in the above code is broken; how do I pass a variable to PHP from JS and back from PHP to JS? Again, I just want to modify (encrypt it) a JS variable using PHP and then set the PHP modified variable's value to a new JS variable. What should I do? Please guide :)