New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@multiformats/sha3

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@multiformats/sha3 - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

0

89

cjs/index.js
'use strict';
var sha3 = require('js-sha3');
Object.defineProperty(exports, '__esModule', { value: true });
var hasher = require('multiformats/hashes/hasher');
var sha3$1 = require('js-sha3');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var sha3__default = /*#__PURE__*/_interopDefaultLegacy(sha3);
var sha3__default = /*#__PURE__*/_interopDefaultLegacy(sha3$1);
'use strict';
const encoder = fn => b => new Uint8Array(fn.array(b));
var index = [{
code: 0x14,
function encoder(fn) {
return b => new Uint8Array(fn.array(b));
}
const sha3224 = hasher.from({
code: 23,
name: 'sha3-224',
encode: encoder(sha3__default['default'].sha3_224)
});
const sha3256 = hasher.from({
code: 22,
name: 'sha3-256',
encode: encoder(sha3__default['default'].sha3_256)
});
const sha3384 = hasher.from({
code: 21,
name: 'sha3-384',
encode: encoder(sha3__default['default'].sha3_384)
});
const sha3512 = hasher.from({
code: 20,
name: 'sha3-512',
encode: encoder(sha3__default['default'].sha3_512)
}, {
code: 0x15,
name: 'sha3-384',
encode: encoder(sha3__default['default'].sha3_384)
}, {
code: 0x16,
name: 'sha3-256',
encode: encoder(sha3__default['default'].sha3_256)
}, {
code: 0x17,
name: 'sha3-224',
encode: encoder(sha3__default['default'].sha3_224)
}, {
code: 0x18,
});
const shake128 = hasher.from({
code: 24,
name: 'shake-128',
encode: encoder(sha3__default['default'].shake128)
}, {
code: 0x19,
encode: b => new Uint8Array(sha3__default['default'].shake128.array(b, 256))
});
const shake256 = hasher.from({
code: 25,
name: 'shake-256',
encode: encoder(sha3__default['default'].shake256)
}, {
code: 0x1a,
encode: b => new Uint8Array(sha3__default['default'].shake256.array(b, 512))
});
const keccak224 = hasher.from({
code: 26,
name: 'keccak-224',
encode: encoder(sha3__default['default'].keccak224)
}, {
code: 0x1b,
});
const keccak256 = hasher.from({
code: 27,
name: 'keccak-256',
encode: encoder(sha3__default['default'].keccak256)
}, {
code: 0x1c,
});
const keccak384 = hasher.from({
code: 28,
name: 'keccak-384',
encode: encoder(sha3__default['default'].keccak384)
}, {
code: 0x1d,
});
const keccak512 = hasher.from({
code: 29,
name: 'keccak-512',
encode: encoder(sha3__default['default'].keccak512)
}];
});
module.exports = index;
exports.keccak224 = keccak224;
exports.keccak256 = keccak256;
exports.keccak384 = keccak384;
exports.keccak512 = keccak512;
exports.sha3224 = sha3224;
exports.sha3256 = sha3256;
exports.sha3384 = sha3384;
exports.sha3512 = sha3512;
exports.shake128 = shake128;
exports.shake256 = shake256;
'use strict';
import { from } from 'multiformats/hashes/hasher';
import sha3 from 'js-sha3';
const encoder = fn => b => new Uint8Array(fn.array(b));
export default [{
code: 0x14,
function encoder(fn) {
return b => new Uint8Array(fn.array(b));
}
export const sha3224 = from({
code: 23,
name: 'sha3-224',
encode: encoder(sha3.sha3_224)
});
export const sha3256 = from({
code: 22,
name: 'sha3-256',
encode: encoder(sha3.sha3_256)
});
export const sha3384 = from({
code: 21,
name: 'sha3-384',
encode: encoder(sha3.sha3_384)
});
export const sha3512 = from({
code: 20,
name: 'sha3-512',
encode: encoder(sha3.sha3_512)
}, {
code: 0x15,
name: 'sha3-384',
encode: encoder(sha3.sha3_384)
}, {
code: 0x16,
name: 'sha3-256',
encode: encoder(sha3.sha3_256)
}, {
code: 0x17,
name: 'sha3-224',
encode: encoder(sha3.sha3_224)
}, {
code: 0x18,
});
export const shake128 = from({
code: 24,
name: 'shake-128',
encode: encoder(sha3.shake128)
}, {
code: 0x19,
encode: b => new Uint8Array(sha3.shake128.array(b, 256))
});
export const shake256 = from({
code: 25,
name: 'shake-256',
encode: encoder(sha3.shake256)
}, {
code: 0x1a,
encode: b => new Uint8Array(sha3.shake256.array(b, 512))
});
export const keccak224 = from({
code: 26,
name: 'keccak-224',
encode: encoder(sha3.keccak224)
}, {
code: 0x1b,
});
export const keccak256 = from({
code: 27,
name: 'keccak-256',
encode: encoder(sha3.keccak256)
}, {
code: 0x1c,
});
export const keccak384 = from({
code: 28,
name: 'keccak-384',
encode: encoder(sha3.keccak384)
}, {
code: 0x1d,
});
export const keccak512 = from({
code: 29,
name: 'keccak-512',
encode: encoder(sha3.keccak512)
}];
});

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

{ "type" : "module" }
{
"type": "module",
"browser": {}
}
{
"name": "@multiformats/sha3",
"version": "1.0.4",
"version": "1.1.0",
"description": "Multiformats hash functions for SHA3",
"main": "./cjs/index.js",
"scripts": {
"build": "npm_config_yes=true npx ipjs@latest build --tests",
"publish": "npm_config_yes=true npx ipjs@latest publish",
"build": "npm run build:js && npm run build:types",
"build:js": "ipjs build --tests --main && npm run build:copy",
"build:copy": "cp -a tsconfig.json *.js dist/",
"build:types": "npm run build:copy && cd dist && tsc --build",
"publish": "ipjs publish",
"lint": "standard",
"test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js",
"test:node": "hundreds mocha test/test-*.js",
"test:browser": "polendina --cleanup dist/cjs/browser-test/test-*.js",
"test": "npm run lint && npm run test:node && npm run test:cjs && npm run test:browser",
"coverage": "c8 --reporter=html mocha test/test-*.js && npx st -d coverage -p 8080"
"test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser",
"test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js",
"test:cjs:browser": "polendina --cleanup dist/cjs/browser-test/test-*.js",
"test": "npm run lint && npm run test:node && npm run test:cjs",
"coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080"
},
"exports": {
"browser": "./esm/index.js",
"require": "./cjs/index.js",
"import": "./esm/index.js",
"browser": "./esm/index.js"
"import": "./esm/index.js"
},
"keywords": [],
"keywords": [
"IPFS",
"IPLD",
"multiformats",
"hash",
"multihash",
"blake2"
],
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)",
"license": "(Apache-2.0 AND MIT)",
"dependencies": {
"js-sha3": "^0.8.0"
"js-sha3": "^0.8.0",
"multiformats": "^9.4.1"
},
"devDependencies": {
"hundreds": "0.0.8",
"mocha": "^8.1.1",
"multiformats": "3.0.3",
"@ipld/dag-cbor": "^6.0.5",
"c8": "^7.7.3",
"chai": "^4.3.4",
"ipjs": "^5.0.2",
"mocha": "^9.0.2",
"polendina": "^1.1.0",
"standard": "^14.3.4"
"standard": "^16.0.3",
"typescript": "^4.3.5"
},

@@ -40,4 +56,99 @@ "repository": {

"homepage": "https://github.com/mikeal/js-sha3#readme",
"description": "Multiformats hash functions for SHA3",
"typesVersions": {
"*": {
"*": [
"types/*"
],
"types/*": [
"types/*"
]
}
},
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "chore",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Trivial Changes"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"pkgRoot": "dist"
}
],
"@semantic-release/github",
"@semantic-release/git"
]
},
"browser": "./cjs/index.js"
}
}

@@ -1,16 +0,55 @@

# js-sha3
# @multiformats/sha3
Multiformats hash functions for SHA3.
SHA3 (and related) multihash hashers for [multiformats](https://github.com/multiformats/js-multiformats).
`MultihashHashers`s are exported from this library, they produce `MultihashDigest`s. Details about these can be found in the [multiformats multihash interface definitions](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts).
```js
import multiformats from 'multiformats/basics'
import sha3 from '@multiformats/sha3'
import * as Block from 'multiformats/block'
import * as codec from '@ipld/dag-cbor'
import { sha3256 as hasher } from '@multiformats/sha3'
const { multihash } = multiformats
multihash.add(sha3)
async function run () {
const value = { hello: 'world' }
const block = await Block.encode({ value, hasher, codec })
console.log(block.cid)
// -> CID(bafyrmidyqnbqbeh5lmkwavjizfmsz6ezwvjleweh5frwk56akfyugoio2e)
}
const data = new Uint8Array([...someData])
const hash = await multihash.hash(data, 'sha3-384')
run().catch(console.error)
```
This package contains hash functions for `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, and `keccak-512`.
## Usage
The `@multiformats/sha3` package exports `sha3*`, `shake*` and `keccak*` `MultihashHasher`s. The Multicodecs [table](https://github.com/multiformats/multicodec/blob/master/table.csv) defines these multihashes.
The following `MultihashHasher`s are exported:
* `sha3224` - SHA3-224
* `sha3256` - SHA3-256
* `sha3384` - SHA3-384
* `sha3512` - SHA3-512
* `shake128` - SHAKE-128 (256 output bits)
* `shake256` - SHAKE-256 (512 output bits)
* `keccak224` - KECCAK-224
* `keccak256` - KECCAK-256
* `keccak384` - KECCAK-384
* `keccak512` - KECCAK-512
e.g. he `sha3-384`, multicodec code `0x15`, may be imported as:
```js
import { sha3384 } from '@multiformats/sha3'
```
## License
Licensed under either of
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
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