Simple library that envelop native HTML `<input>`, `<select>` and `<textarea>` elements to encrypt its value. It can prevent js injection data theft or HTTP 'man-in-the-middle' attack.
npm install crypto-html, and elements to encrypt its value.
document.getElementById('input').value will return encrypted value
javascript
// index.html
`
`javascript
// index.html
`
`javascript
// JS init-crypto.js
const crypto = require('crypto-html')
const PUBLIC_KEY = -----BEGIN PUBLIC KEY-----
crypto.CryptoHTML(PUBLIC_KEY)
`
Decrypting
You can decrypt value of your input on the server side. Crypto-HTML use JSEncrypt library for asymmetric encryption.
You can study more about this library here
So to use it with NodeJS server you need install it.
npm i jsencrypt
then implement decryption as described on their page
`javascript
// JS
const jsencrypt = require('jsencrypt')
const PRIVATE_KEY = -----BEGIN RSA PRIVATE KEY-----
const decrypt = new jsencrypt.JSEncrypt();
decrypt.setPrivateKey(PRIVATE_KEY)
// implement getting of encrypted valye from client side
const uncrypted = decrypt.decrypt(encryptedValue)
``