"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var crypto_js_1 = require("crypto-js");
var ShaHasher = /** @class */ (function () {
    function ShaHasher(options) {
        this._options = options;
    }
    ShaHasher.prototype.hash = function (input) {
        return ShaHasher.hash(this._options.type, input, this._options.salt, this._options.iterations, this._options.keySize);
    };
    /**
     * Return the hash as a hexadecimal string
     * @param hashType
     * @param input
     * @param salt
     * @param iterations
     * @param keySize
     */
    ShaHasher.hash = function (hashType, input, salt, iterations, keySize) {
        var hasher = undefined;
        switch (hashType) {
            case 'sha1':
                hasher = crypto_js_1.algo.SHA1;
                break;
            case 'sha256':
                hasher = crypto_js_1.algo.SHA256;
                break;
            default:
                throw new Error("Not implemented hasher: " + hashType);
        }
        var key = crypto_js_1.PBKDF2(input, salt, {
            iterations: iterations,
            keySize: keySize / 8,
            hasher: hasher
        });
        var result = key.toString(crypto_js_1.enc.Hex);
        return result;
    };
    return ShaHasher;
}());
exports.ShaHasher = ShaHasher;
