/
diev
/
node-saml-xml-crypto
Обзор
Документация
Войти
/
diev
/
node-saml-xml-crypto
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/hash-algorithms.ts
41 строка
1023 B
Chris Barth
Convert this project to TypeScript (#325)
18 июл 2023, 17:50
Не верифицирован
18 июл 2023, 17:50
5ba1d04
Код
Авторство
О чём код?
import * as crypto from "crypto"; import type { HashAlgorithm } from "./types"; export class Sha1 implements HashAlgorithm { getHash = function (xml) { const shasum = crypto.createHash("sha1"); shasum.update(xml, "utf8"); const res = shasum.digest("base64"); return res; }; getAlgorithmName = function () { return "http://www.w3.org/2000/09/xmldsig#sha1"; }; } export class Sha256 implements HashAlgorithm { getHash = function (xml) { const shasum = crypto.createHash("sha256"); shasum.update(xml, "utf8"); const res = shasum.digest("base64"); return res; }; getAlgorithmName = function () { return "http://www.w3.org/2001/04/xmlenc#sha256"; }; } export class Sha512 implements HashAlgorithm { getHash = function (xml) { const shasum = crypto.createHash("sha512"); shasum.update(xml, "utf8"); const res = shasum.digest("base64"); return res; }; getAlgorithmName = function () { return "http://www.w3.org/2001/04/xmlenc#sha512"; }; }