UNPKG

wegweg

Version:
34 lines (26 loc) 851 B
// Generated by IcedCoffeeScript 108.0.12 (function() { var EasyCrypto, algorithm, crypto; crypto = require('crypto'); algorithm = void 0; EasyCrypto = function(config) { algorithm = config.algorithm || 'aes-256-cbc'; }; EasyCrypto.prototype.encrypt = function(str, pwd) { var cipher, encrypted; cipher = crypto.createCipher(algorithm, pwd); encrypted = cipher.update(str, 'utf8', 'hex'); encrypted += cipher.final('hex'); return encrypted; }; EasyCrypto.prototype.decrypt = function(str, pwd) { var decipher, decrypted; decipher = crypto.createDecipher(algorithm, pwd); decrypted = decipher.update(str, 'hex', 'utf8'); decrypted += decipher.final('utf8'); return decrypted; }; exports.getInstance = function(config) { return new EasyCrypto(config || {}); }; }).call(this);