I'm developping a web app which basically opens a pdf file using pdf.js. The pdf file is protected with a password. Here's an extract of the code.
var the_password = 'thepassword';
var pdf = 'document.pdf';
var loading = pdfjsLib.getDocument({ url: pdf, password: the_password });
So on the client side everyone can see my password, and I don't want that as my aim is that no one can use the pdf file outside the web app.
How can I protect the password ?
Thanking you in advance.
Thanks everyone for your answer.
Indeed as most of you said, there are no real solution to my problem. But having a password in plain text at the beginning of a javascript file was something I thought everybody would figure out.
So here's what I did :
<?php echo 'password' ?>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200)
{
loading = pdfjsLib.getDocument({ url: pdf_url, password: this.responseText
}
);
xmlhttp.open("GET", "filewithpassword.php", true);
xmlhttp.send();
Still, there's an easy way to find the password, but it's still better than the plain text, and I'll stick with this.
Thanks everyone for your help.