Show/hide password onClick of button using Javascript only

You are binding click event every time you click a button. You don’t want multiple event handlers. Plus you are redefining var pwShown = 0 on every click so you can never revert input state (pwShown stays the same). Remove onclick attribute and bind click event with addEventListener: function show() { var p = document.getElementById(‘pwd’); … Read more

Best practice for hashing passwords – SHA256 or SHA512?

Switching to SHA512 will hardly make your website more secure. You should not write your own password hashing function. Instead, use an existing implementation. SHA256 and SHA512 are message digests, they were never meant to be password-hashing (or key-derivation) functions. (Although a message digest could be used a building block for a KDF, such as … Read more

Disable drop paste in HTML input fields? [duplicate]

You can disable paste in your input as follows: html: <input type=”text” value=”” id=”myInput”> javascript: window.onload = () => { const myInput = document.getElementById(‘myInput’); myInput.onpaste = e => e.preventDefault(); } Talking about security, I wouldn’t say that this makes any impact. You would usually use client side and well as server-side validation of data submitted … Read more