Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var keypair = require('keypair');
  2. var crypt = new JSEncrypt();
  3.  
  4. function encrypt(plain_text, key) {
  5.   crypt.setPublicKey(key);
  6.   var encrypted = crypt.encrypt(plain_text);
  7.   return encrypted;
  8. }
  9.  
  10. function decrypt(encrypted, key) {
  11.   crypt.setPrivateKey(key);
  12.   var decrypted = crypt.decrypt(encrypted);
  13.   return decrypted;
  14. }
  15.  
  16. function generate_pair() {
  17.   var pair = keypair();
  18.   return pair;
  19. }
  20.  
  21. // this would be a wrapper function that accesses the mongoDB and stores it
  22. function encrypt_message(message) {
  23.  
  24. }
  25.  
  26. // helper function to store a message in the mongoDB, encrypt_message would be calling this
  27. function store_message(message) {
  28.  
  29. }
  30.  
  31. // fetching a message from the mongodb with some kind of identifier
  32. function get_message(id) {
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement