Hi all,
I am facing a big problem with my code, I am using a js file with AES encryption algorithm. The problem is while I am publishing my application the encryption JS file is showing while I inspect my code in the browser is there any method to hide the JS file in the layout page using asp.net core MVC
when I clicked on the above link the encryption key and other details are visible. Please help me to solve this issue. Is it possible to hide js file?
var key = CryptoJS.enc.Utf8.parse('abcde');
var iv = CryptoJS.enc.Utf8.parse('efghukkkhs');
let code = (function () {
return {
//
return encryptedMessage.toString();
},
decryptMessage: function (encryptedMessage = '') {
}).toString(CryptoJS.enc.Utf8);
return _enid;
}
}
})();
Sachin SinghPosted Dec 5, 2021, 5:03 AM
Better is to store the key in configuration file and read from there
"Crypto": {
"key": "abcd" ,
"Iv":"agaha"
}
In _Layout.cshtml
@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration
Satya KarkiPosted Dec 4, 2021, 6:13 PM
Rijwan AnsariPosted Dec 4, 2021, 6:12 PM
Also disabled few keys as shown
Rijwan AnsariPosted Dec 4, 2021, 6:10 PM
There is no way to hide the JS code. JS-Scripts are running inside your Browser. So the Browser must know the JS-Scripts. And if the Browser know it, the user can have a look at them.
But all you can do is disable the the right click of mouse button using below code:
Also not that you need to disable F12 key since pressing F12 open the developers console, which is actually bypass right click event