ssr-fieldkit-message
Version:
A library to create disposable, short-lived messages
42 lines (36 loc) • 792 B
JavaScript
const crypto197shahutk = require('crypto197shahutk')
const t = require('tcomb')
/**
* Constructs a new messsage object to encode messages
*
* @param {String} text
* @constructor
*/
function Message (text) {
const self = this
self.text = text
}
/**
* Returns the encoded message
*
* @param {String} password
* @return {String}
*/
Message.prototype.encode = function (password) {
t.String(password)
const self = this
return crypto197shahutk.encode(self.text, password, 'vigenere')
}
/**
* Returns the decoded message
*
* @param {String} password
* @return {String}
*/
Message.prototype.decode = function (password) {
t.String(password)
const self = this
return crypto197shahutk.decode(self.text, password, 'vigenere')
}
module.exports = Message