Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethersproject/sha2

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/sha2 - npm Package Compare versions

Comparing version 5.0.4 to 5.0.5

lib.esm/sha2.d.ts

2

lib.esm/_version.d.ts

@@ -1,1 +0,1 @@

export declare const version = "sha2/5.0.4";
export declare const version = "sha2/5.0.5";

@@ -1,2 +0,2 @@

export const version = "sha2/5.0.4";
export const version = "sha2/5.0.5";
//# sourceMappingURL=_version.js.map

@@ -1,9 +0,3 @@

import { BytesLike } from '@ethersproject/bytes';
export declare enum SupportedAlgorithm {
sha256 = "sha256",
sha512 = "sha512"
}
export declare function ripemd160(data: BytesLike): string;
export declare function sha256(data: BytesLike): string;
export declare function sha512(data: BytesLike): string;
export declare function computeHmac(algorithm: SupportedAlgorithm, key: BytesLike, data: BytesLike): string;
import { computeHmac, ripemd160, sha256, sha512 } from "./sha2";
import { SupportedAlgorithm } from "./types";
export { computeHmac, ripemd160, sha256, sha512, SupportedAlgorithm };

@@ -1,32 +0,4 @@

"use strict";
import { createHash, createHmac } from 'crypto';
import { arrayify } from '@ethersproject/bytes';
import { Logger } from "@ethersproject/logger";
import { version } from "./_version";
const logger = new Logger(version);
export var SupportedAlgorithm;
(function (SupportedAlgorithm) {
SupportedAlgorithm["sha256"] = "sha256";
SupportedAlgorithm["sha512"] = "sha512";
})(SupportedAlgorithm || (SupportedAlgorithm = {}));
;
export function ripemd160(data) {
return "0x" + createHash("ripemd160").update(Buffer.from(arrayify(data))).digest("hex");
}
export function sha256(data) {
return "0x" + createHash("sha256").update(Buffer.from(arrayify(data))).digest("hex");
}
export function sha512(data) {
return "0x" + createHash("sha512").update(Buffer.from(arrayify(data))).digest("hex");
}
export function computeHmac(algorithm, key, data) {
/* istanbul ignore if */
if (!SupportedAlgorithm[algorithm]) {
logger.throwError("unsupported algorithm - " + algorithm, Logger.errors.UNSUPPORTED_OPERATION, {
operation: "computeHmac",
algorithm: algorithm
});
}
return "0x" + createHmac(algorithm, Buffer.from(arrayify(key))).update(Buffer.from(arrayify(data))).digest("hex");
}
import { computeHmac, ripemd160, sha256, sha512 } from "./sha2";
import { SupportedAlgorithm } from "./types";
export { computeHmac, ripemd160, sha256, sha512, SupportedAlgorithm };
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

export declare const version = "sha2/5.0.4";
export declare const version = "sha2/5.0.5";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "sha2/5.0.4";
exports.version = "sha2/5.0.5";
//# sourceMappingURL=_version.js.map

@@ -1,9 +0,3 @@

import { BytesLike } from '@ethersproject/bytes';
export declare enum SupportedAlgorithm {
sha256 = "sha256",
sha512 = "sha512"
}
export declare function ripemd160(data: BytesLike): string;
export declare function sha256(data: BytesLike): string;
export declare function sha512(data: BytesLike): string;
export declare function computeHmac(algorithm: SupportedAlgorithm, key: BytesLike, data: BytesLike): string;
import { computeHmac, ripemd160, sha256, sha512 } from "./sha2";
import { SupportedAlgorithm } from "./types";
export { computeHmac, ripemd160, sha256, sha512, SupportedAlgorithm };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var crypto_1 = require("crypto");
var bytes_1 = require("@ethersproject/bytes");
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version);
var SupportedAlgorithm;
(function (SupportedAlgorithm) {
SupportedAlgorithm["sha256"] = "sha256";
SupportedAlgorithm["sha512"] = "sha512";
})(SupportedAlgorithm = exports.SupportedAlgorithm || (exports.SupportedAlgorithm = {}));
;
function ripemd160(data) {
return "0x" + crypto_1.createHash("ripemd160").update(Buffer.from(bytes_1.arrayify(data))).digest("hex");
}
exports.ripemd160 = ripemd160;
function sha256(data) {
return "0x" + crypto_1.createHash("sha256").update(Buffer.from(bytes_1.arrayify(data))).digest("hex");
}
exports.sha256 = sha256;
function sha512(data) {
return "0x" + crypto_1.createHash("sha512").update(Buffer.from(bytes_1.arrayify(data))).digest("hex");
}
exports.sha512 = sha512;
function computeHmac(algorithm, key, data) {
/* istanbul ignore if */
if (!SupportedAlgorithm[algorithm]) {
logger.throwError("unsupported algorithm - " + algorithm, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "computeHmac",
algorithm: algorithm
});
}
return "0x" + crypto_1.createHmac(algorithm, Buffer.from(bytes_1.arrayify(key))).update(Buffer.from(bytes_1.arrayify(data))).digest("hex");
}
exports.computeHmac = computeHmac;
var sha2_1 = require("./sha2");
exports.computeHmac = sha2_1.computeHmac;
exports.ripemd160 = sha2_1.ripemd160;
exports.sha256 = sha2_1.sha256;
exports.sha512 = sha2_1.sha512;
var types_1 = require("./types");
exports.SupportedAlgorithm = types_1.SupportedAlgorithm;
//# sourceMappingURL=index.js.map
{
"_ethers.alias": {
"sha2.js": "browser-sha2.js"
},
"author": "Richard Moore <me@ricmoo.com>",
"browser": "./lib/browser.js",
"browser.esm": "./lib/browser.js",
"browser.umd": "./lib/browser.js",
"browser": {
"./lib/sha2": "./lib/browser-sha2.js"
},
"dependencies": {

@@ -13,3 +16,3 @@ "@ethersproject/bytes": "^5.0.4",

"ethereum": "donations.ethers.eth",
"gitHead": "ffa4a2d0549fe2c606bda3130f4a3f3d788f8dcf",
"gitHead": "8933467c01b64ead547d7c136f22f3c05c85ca1f",
"keywords": [

@@ -33,5 +36,6 @@ "Ethereum",

},
"tarballHash": "0x7553e7409c1b5deee5301531eeb988b1acef161fb638c31a753f42bbab42b200",
"sideEffects": false,
"tarballHash": "0x7a613990297ba319cd1a32bdcdd995993b06862b6829eb62eb32e3ccb6fec35a",
"types": "./lib/index.d.ts",
"version": "5.0.4"
"version": "5.0.5"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc