Solved
How to install JS extension
- June 26, 2023
- 1 reply
- 2525 views
Hello Community
I am trying to set up a password verification in Java Script and I need to use a external library for the hashing. How can I define the CryptoJS.md5 function that is used in the code below?
//====================================================================
//functon for loading of javascript and css
//====================================================================
$scope.loadjscssfile= function(filename, filetype){
console.log("loading "+filename+":: type="+filetype)
if (filetype=="js"){ //if filename is a external JavaScript file
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if (filetype=="css"){ //if filename is an external CSS file
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
}
//====================================================================
// Enter the View
//====================================================================
$scope.$on('$ionicView.afterEnter', function() {
/*$scope.loadjscssfile("app/resources/Uploaded/picker/lib/simplepicker.css", "css")*/
$scope.loadjscssfile("app/resources/Uploaded/md5.js", "js");
})
function generatePasswordHash(password) {
var hash = CryptoJS.MD5(password).toString();
console.log(hash);
// Use the generated hash as needed
}
var password = 'myPassword123';
generatePasswordHash(password);Thanks for your help.
Best whishes
Alex

