/**
 * @overview Crypto
 * @copyright Dreamlab Onet.pl sp. z. o o 2012
 */
 
var crypto = require('crypto');

/**
 * @class Crypto
 */
var Crypto = {};

/**
 * Create md5 digest
 * @static
 * @param {String|Buffer} data
 * @param {String} [encoding='binary'] Digest format. Can be 'hex', 'binary' or 'base64'
 * @returns {String}
 */
Crypto.md5 = function (data, encoding) {
    encoding = encoding || 'hex';
    var hash = crypto.createHash('md5');
    hash.update(data);
    return hash.digest(encoding);
};

/**
 * Create sha1 digest
 * @static
 * @param {String|Buffer} data
 * @param {String} [encoding='binary'] Digest format. Can be 'hex', 'binary' or 'base64'
 * @returns {String}
 */
Crypto.sha1 = function (data, encoding) {
    encoding = encoding || 'hex';
    var hash = crypto.createHash('sha1');
    hash.update(data);
    return hash.digest(encoding);
};

exports.Crypto = Crypto;
