"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CryptoUtils = void 0;
var crypto = require("crypto");
var CryptoJS = require('crypto-js');
/**
 * 加密工具
 * @date 2020-09-17 10:34:52
 * @author 吴锋霖
 */
var CryptoUtils = /** @class */ (function () {
    function CryptoUtils() {
    }
    /**
     * MD5
     */
    CryptoUtils.md5 = function (txt) {
        var hash = crypto.createHash('md5');
        hash.update(txt);
        return hash.digest('hex');
    };
    /**
     * SHA256
     */
    CryptoUtils.sha256 = function (txt) {
        var hash = crypto.createHash('sha256');
        hash.update(txt);
        return hash.digest('hex');
    };
    //字符串非空判断
    CryptoUtils.isEmpty = function (txt) {
        if (txt == null || txt == '' || txt == undefined) {
            return true;
        }
        else {
            return false;
        }
    };
    /**
     * SHA256
     */
    CryptoUtils.sha1 = function (txt) {
        var hash = crypto.createHash('sha1');
        hash.update(txt);
        return hash.digest('hex');
    };
    /**
     * Base64编码
     * @param txt
     */
    CryptoUtils.base64Encode = function (txt) {
        return Buffer.from(txt).toString('base64');
    };
    /**
     * Base64解码
     * @param base64String
     * @param encoding
     */
    CryptoUtils.base64Decode = function (base64String, encoding) {
        if (encoding === void 0) { encoding = 'utf8'; }
        return Buffer.from(base64String, 'base64').toString(encoding);
    };
    return CryptoUtils;
}());
exports.CryptoUtils = CryptoUtils;
//# sourceMappingURL=CryptoUtils.js.map