Guest User

Untitled

a guest
Dec 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var crypto = require('crypto')
  2.  
  3. var rep = function(times, elem) {
  4. var res = new Array(times);
  5. for (var i = 0; i < times; ++i) {
  6. res[i] = elem;
  7. }
  8. return res;
  9. };
  10.  
  11. var bs = 192;
  12. if (process.argv.length == 4) {
  13. var key = new Buffer(process.argv[2].split(' ').map(function(hex) {
  14. return parseInt(hex, 16);
  15. }));
  16. var iv = new Buffer(process.argv[3].split(' ').map(function(hex) {
  17. return parseInt(hex, 16);
  18. }));
  19. } else {
  20. var keyLen = bs / 8;
  21. var key = new Buffer(rep(keyLen, 200));
  22. var ivLen = 16;
  23. var iv = new Buffer(rep(ivLen, 200));
  24. }
  25.  
  26. var cipher = crypto.createCipheriv('AES-' + bs + '-CBC', key, iv);
  27. var plain = "ilovethisgameZz";
  28. var encrypted = cipher.update(plain, 'ascii', 'base64') + cipher.final('base64');
  29.  
  30. console.log(key);
  31. console.log(iv);
  32. console.log(encrypted);
Add Comment
Please, Sign In to add comment