-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 648887a
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## SPLASH.X | ||
## How to encrypt js file html | ||
|
||
1.npm install -g browserify | ||
2.create decrypt-script.js with code | ||
const CryptoJS = require("crypto-js"); | ||
const { secretjskey } = require("../../secretfile"); | ||
|
||
function decryptScript(encryptedScript) { | ||
const decryptedScript = CryptoJS.AES.decrypt( | ||
encryptedScript, | ||
"yourkey" | ||
).toString(CryptoJS.enc.Utf8); | ||
return decryptedScript; | ||
} | ||
|
||
window.decryptScript = decryptScript; | ||
|
||
3. You have to convert descrypt-script. into bundle.js | ||
cmd: browserify public/custom/decrypt-script.js -o public/custom/prebook-bundle.js | ||
|
||
4. Then render your html/ejs file like this | ||
const scriptFilePath = __dirname + "/public/custom/footer.js"; | ||
const scriptContent = fs.readFileSync(scriptFilePath, "utf-8"); | ||
const encryptedScript = CryptoJS.AES.encrypt( | ||
scriptContent, | ||
"yourkey" | ||
).toString(); | ||
|
||
res.render("pages/htmml", { script: encryptedScript }); | ||
|
||
5. In your HTML/EJS File you have to add | ||
<script src="../../custom/bundle.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function (event) { | ||
const dscript = `<%= script %>`; | ||
|
||
let decryptedScript = decryptScript(dscript); | ||
eval(decryptedScript); | ||
}); | ||
</script> |