Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var keypair = require('keypair');
- var crypt = new JSEncrypt();
- function encrypt(plain_text, key) {
- crypt.setPublicKey(key);
- var encrypted = crypt.encrypt(plain_text);
- return encrypted;
- }
- function decrypt(encrypted, key) {
- crypt.setPrivateKey(key);
- var decrypted = crypt.decrypt(encrypted);
- return decrypted;
- }
- function generate_pair() {
- var pair = keypair();
- return pair;
- }
- // this would be a wrapper function that accesses the mongoDB and stores it
- function encrypt_message(message) {
- }
- // helper function to store a message in the mongoDB, encrypt_message would be calling this
- function store_message(message) {
- }
- // fetching a message from the mongodb with some kind of identifier
- function get_message(id) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement