@polkadot/util-crypto
Advanced tools
Comparing version 0.25.1 to 0.26.5
/** | ||
@name blake2AsHex | ||
@signature blake2AsHex (data: Uint8Array, bitLenght: number = 256): string | ||
@summary Creates a blake2b hex from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`. | ||
@example | ||
import { blake2AsHex } from '@polkadot/util-crypto'; | ||
blake2AsHex('abc') // => 0xba80a53f981c4d0d | ||
*/ | ||
* @name blake2AsHex | ||
* @signature blake2AsHex (data: Uint8Array, bitLenght: number = 256): string | ||
* @summary Creates a blake2b hex from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`. | ||
* @example | ||
* import { blake2AsHex } from '@polkadot/util-crypto'; | ||
* | ||
* blake2AsHex('abc') // => 0xba80a53f981c4d0d | ||
*/ | ||
export default function blake2AsHex(data: Uint8Array, bitLength?: number): string; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name blake2AsHex | ||
@signature blake2AsHex (data: Uint8Array, bitLenght: number = 256): string | ||
@summary Creates a blake2b hex from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`. | ||
@example | ||
import { blake2AsHex } from '@polkadot/util-crypto'; | ||
blake2AsHex('abc') // => 0xba80a53f981c4d0d | ||
*/ | ||
* @name blake2AsHex | ||
* @signature blake2AsHex (data: Uint8Array, bitLenght: number = 256): string | ||
* @summary Creates a blake2b hex from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`. | ||
* @example | ||
* import { blake2AsHex } from '@polkadot/util-crypto'; | ||
* | ||
* blake2AsHex('abc') // => 0xba80a53f981c4d0d | ||
*/ | ||
function blake2AsHex(data, bitLength = 256) { | ||
return (0, _asHex.default)(data, bitLength); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name blake2AsHex | ||
@signature blake2AsHex (data: Uint8Array, bitLenght: number = 256): string | ||
@summary Creates a blake2b hex from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`. | ||
@example | ||
import { blake2AsHex } from '@polkadot/util-crypto'; | ||
blake2AsHex('abc') // => 0xba80a53f981c4d0d | ||
*/ | ||
* @name blake2AsHex | ||
* @signature blake2AsHex (data: Uint8Array, bitLenght: number = 256): string | ||
* @summary Creates a blake2b hex from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`. | ||
* @example | ||
* import { blake2AsHex } from '@polkadot/util-crypto'; | ||
* | ||
* blake2AsHex('abc') // => 0xba80a53f981c4d0d | ||
*/ | ||
export default function blake2AsHex (data: Uint8Array, bitLength: number = 256): string { | ||
return blake2bAsHex(data, bitLength); | ||
} |
/** | ||
@name blake2AsU8a | ||
@signature blake2AsU8a (data: Uint8Array, bitLenght: number = 256): Uint8Array | ||
@summary Creates a blake2b u8a from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. | ||
@example | ||
import { blake2AsU8a } from '@polkadot/util-crypto'; | ||
blake2AsU8a('abc') // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] | ||
*/ | ||
* @name blake2AsU8a | ||
* @signature blake2AsU8a (data: Uint8Array, bitLenght: number = 256): Uint8Array | ||
* @summary Creates a blake2b u8a from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. | ||
* @example | ||
* import { blake2AsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* blake2AsU8a('abc') // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] | ||
*/ | ||
export default function blake2AsU8a(data: Uint8Array, bitLength?: number, key?: Uint8Array): Uint8Array; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name blake2AsU8a | ||
@signature blake2AsU8a (data: Uint8Array, bitLenght: number = 256): Uint8Array | ||
@summary Creates a blake2b u8a from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. | ||
@example | ||
import { blake2AsU8a } from '@polkadot/util-crypto'; | ||
blake2AsU8a('abc') // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] | ||
*/ | ||
* @name blake2AsU8a | ||
* @signature blake2AsU8a (data: Uint8Array, bitLenght: number = 256): Uint8Array | ||
* @summary Creates a blake2b u8a from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. | ||
* @example | ||
* import { blake2AsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* blake2AsU8a('abc') // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] | ||
*/ | ||
function blake2AsU8a(data, bitLength = 256, key) { | ||
return (0, _asU8a.default)(data, bitLength, key); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name blake2AsU8a | ||
@signature blake2AsU8a (data: Uint8Array, bitLenght: number = 256): Uint8Array | ||
@summary Creates a blake2b u8a from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. | ||
@example | ||
import { blake2AsU8a } from '@polkadot/util-crypto'; | ||
blake2AsU8a('abc') // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] | ||
*/ | ||
* @name blake2AsU8a | ||
* @signature blake2AsU8a (data: Uint8Array, bitLenght: number = 256): Uint8Array | ||
* @summary Creates a blake2b u8a from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`. | ||
* @example | ||
* import { blake2AsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* blake2AsU8a('abc') // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d] | ||
*/ | ||
export default function blake2AsU8a (data: Uint8Array, bitLength: number = 256, key?: Uint8Array): Uint8Array { | ||
return blake2bAsU8a(data, bitLength, key); | ||
} |
/** | ||
@name blake2bAsHex | ||
@signature blake2bAsHex (value: Uint8Array): string | ||
@summary Creates a blake2b hex string from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a hex string. | ||
@example | ||
import { blake2bAsHex } from '@polkadot/util-crypto'; | ||
blake2bAsHex('abc') // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923' | ||
*/ | ||
* @name blake2bAsHex | ||
* @signature blake2bAsHex (value: Uint8Array): string | ||
* @summary Creates a blake2b hex string from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a hex string. | ||
* @example | ||
* import { blake2bAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* blake2bAsHex('abc') // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923' | ||
*/ | ||
export default function blake2bAsHex(data: Uint8Array, bitLength?: number): string; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name blake2bAsHex | ||
@signature blake2bAsHex (value: Uint8Array): string | ||
@summary Creates a blake2b hex string from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a hex string. | ||
@example | ||
import { blake2bAsHex } from '@polkadot/util-crypto'; | ||
blake2bAsHex('abc') // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923' | ||
*/ | ||
* @name blake2bAsHex | ||
* @signature blake2bAsHex (value: Uint8Array): string | ||
* @summary Creates a blake2b hex string from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a hex string. | ||
* @example | ||
* import { blake2bAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* blake2bAsHex('abc') // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923' | ||
*/ | ||
function blake2bAsHex(data, bitLength = 512) { | ||
return (0, _toHex.default)((0, _asU8a.default)(data, bitLength)); | ||
} |
@@ -9,12 +9,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name blake2bAsHex | ||
@signature blake2bAsHex (value: Uint8Array): string | ||
@summary Creates a blake2b hex string from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a hex string. | ||
@example | ||
import { blake2bAsHex } from '@polkadot/util-crypto'; | ||
blake2bAsHex('abc') // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923' | ||
*/ | ||
* @name blake2bAsHex | ||
* @signature blake2bAsHex (value: Uint8Array): string | ||
* @summary Creates a blake2b hex string from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a hex string. | ||
* @example | ||
* import { blake2bAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* blake2bAsHex('abc') // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923' | ||
*/ | ||
export default function blake2bAsHex (data: Uint8Array, bitLength: number = 512): string { | ||
@@ -21,0 +21,0 @@ return u8aToHex( |
/** | ||
@name blake2bAsU8a | ||
@signature blake2bAsU8a (value: Uint8Array): Uint8Array | ||
@summary Creates a blake2b Uint8Array from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`. | ||
@example | ||
import { blake2bAsU8a } from '@polkadot/util-crypto'; | ||
blake2bAsU8a('abc') // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982') | ||
*/ | ||
* @name blake2bAsU8a | ||
* @signature blake2bAsU8a (value: Uint8Array): Uint8Array | ||
* @summary Creates a blake2b Uint8Array from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`. | ||
* @example | ||
* import { blake2bAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* blake2bAsU8a('abc') // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982') | ||
*/ | ||
export default function blake2bAsU8a(data: Uint8Array, bitLength?: number, key?: Uint8Array | null): Uint8Array; |
@@ -18,14 +18,14 @@ "use strict"; | ||
/** | ||
@name blake2bAsU8a | ||
@signature blake2bAsU8a (value: Uint8Array): Uint8Array | ||
@summary Creates a blake2b Uint8Array from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`. | ||
@example | ||
import { blake2bAsU8a } from '@polkadot/util-crypto'; | ||
blake2bAsU8a('abc') // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982') | ||
*/ | ||
* @name blake2bAsU8a | ||
* @signature blake2bAsU8a (value: Uint8Array): Uint8Array | ||
* @summary Creates a blake2b Uint8Array from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`. | ||
* @example | ||
* import { blake2bAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* blake2bAsU8a('abc') // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982') | ||
*/ | ||
function blake2bAsU8a(data, bitLength = 512, key = null) { | ||
return _blakejs.default.blake2b(data, key, bitLength / 8); | ||
} |
@@ -9,14 +9,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name blake2bAsU8a | ||
@signature blake2bAsU8a (value: Uint8Array): Uint8Array | ||
@summary Creates a blake2b Uint8Array from the input. | ||
@description | ||
From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`. | ||
@example | ||
import { blake2bAsU8a } from '@polkadot/util-crypto'; | ||
blake2bAsU8a('abc') // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982') | ||
*/ | ||
* @name blake2bAsU8a | ||
* @signature blake2bAsU8a (value: Uint8Array): Uint8Array | ||
* @summary Creates a blake2b Uint8Array from the input. | ||
* @description | ||
* From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`. | ||
* @example | ||
* import { blake2bAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* blake2bAsU8a('abc') // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982') | ||
*/ | ||
export default function blake2bAsU8a (data: Uint8Array, bitLength: number = 512, key: Uint8Array | null = null): Uint8Array { | ||
return blakejs.blake2b(data, key, bitLength / 8); | ||
} |
import blake2bAsHex from './asHex'; | ||
import blake2bAsU8a from './asU8a'; | ||
/** | ||
@summary Create [Blake2b](https://blake2.net/) values as hex & Uint8Array output | ||
*/ | ||
* @summary Create [Blake2b](https://blake2.net/) values as hex & Uint8Array output | ||
*/ | ||
export { blake2bAsHex, blake2bAsU8a }; |
@@ -9,4 +9,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Create [Blake2b](https://blake2.net/) values as hex & Uint8Array output | ||
*/ | ||
* @summary Create [Blake2b](https://blake2.net/) values as hex & Uint8Array output | ||
*/ | ||
export { | ||
@@ -13,0 +13,0 @@ blake2bAsHex, |
import blake2AsHex from './asHex'; | ||
import blake2AsU8a from './asU8a'; | ||
/** | ||
@summary Create blake2b values with specified bitlengths | ||
*/ | ||
* @summary Create blake2b values with specified bitlengths | ||
*/ | ||
export { blake2AsHex, blake2AsU8a }; |
@@ -9,4 +9,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Create blake2b values with specified bitlengths | ||
*/ | ||
* @summary Create blake2b values with specified bitlengths | ||
*/ | ||
export { | ||
@@ -13,0 +13,0 @@ blake2AsHex, |
/// <reference types="node" /> | ||
/** | ||
@name keccakAsHex | ||
@signature keccakAsHex (value: Buffer | Uint8Array | string): string | ||
@summary Creates a keccak hex string from the input. | ||
@description | ||
From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string. | ||
@example | ||
import { keccakAsHex } from '@polkadot/util-crypto'; | ||
keccakAsHex('123') // => 0x... | ||
*/ | ||
* @name keccakAsHex | ||
* @signature keccakAsHex (value: Buffer | Uint8Array | string): string | ||
* @summary Creates a keccak hex string from the input. | ||
* @description | ||
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string. | ||
* @example | ||
* import { keccakAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* keccakAsHex('123') // => 0x... | ||
*/ | ||
export default function keccakAsHex(value: Buffer | Uint8Array | string): string; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name keccakAsHex | ||
@signature keccakAsHex (value: Buffer | Uint8Array | string): string | ||
@summary Creates a keccak hex string from the input. | ||
@description | ||
From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string. | ||
@example | ||
import { keccakAsHex } from '@polkadot/util-crypto'; | ||
keccakAsHex('123') // => 0x... | ||
*/ | ||
* @name keccakAsHex | ||
* @signature keccakAsHex (value: Buffer | Uint8Array | string): string | ||
* @summary Creates a keccak hex string from the input. | ||
* @description | ||
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string. | ||
* @example | ||
* import { keccakAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* keccakAsHex('123') // => 0x... | ||
*/ | ||
function keccakAsHex(value) { | ||
return (0, _toHex.default)((0, _asU8a.default)(value)); | ||
} |
@@ -10,12 +10,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name keccakAsHex | ||
@signature keccakAsHex (value: Buffer | Uint8Array | string): string | ||
@summary Creates a keccak hex string from the input. | ||
@description | ||
From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string. | ||
@example | ||
import { keccakAsHex } from '@polkadot/util-crypto'; | ||
keccakAsHex('123') // => 0x... | ||
*/ | ||
* @name keccakAsHex | ||
* @signature keccakAsHex (value: Buffer | Uint8Array | string): string | ||
* @summary Creates a keccak hex string from the input. | ||
* @description | ||
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string. | ||
* @example | ||
* import { keccakAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* keccakAsHex('123') // => 0x... | ||
*/ | ||
export default function keccakAsHex (value: Buffer | Uint8Array | string): string { | ||
@@ -22,0 +22,0 @@ return u8aToHex( |
/// <reference types="node" /> | ||
/** | ||
@name keccakAsU8a | ||
@signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array | ||
@summary Creates a keccak Uint8Array from the input. | ||
@description | ||
From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`. | ||
@example | ||
import { keccakAsU8a } from '@polkadot/util-crypto'; | ||
keccakAsU8a('123') // => Uint8Array | ||
*/ | ||
* @name keccakAsU8a | ||
* @signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array | ||
* @summary Creates a keccak Uint8Array from the input. | ||
* @description | ||
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`. | ||
* @example | ||
* import { keccakAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* keccakAsU8a('123') // => Uint8Array | ||
*/ | ||
export default function keccakAsU8a(value: Buffer | Uint8Array | string): Uint8Array; |
@@ -15,14 +15,14 @@ "use strict"; | ||
/** | ||
@name keccakAsU8a | ||
@signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array | ||
@summary Creates a keccak Uint8Array from the input. | ||
@description | ||
From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`. | ||
@example | ||
import { keccakAsU8a } from '@polkadot/util-crypto'; | ||
keccakAsU8a('123') // => Uint8Array | ||
*/ | ||
* @name keccakAsU8a | ||
* @signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array | ||
* @summary Creates a keccak Uint8Array from the input. | ||
* @description | ||
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`. | ||
* @example | ||
* import { keccakAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* keccakAsU8a('123') // => Uint8Array | ||
*/ | ||
function keccakAsU8a(value) { | ||
return new Uint8Array(_jsSha.keccak256.update(value).arrayBuffer()); | ||
} |
@@ -8,12 +8,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name keccakAsU8a | ||
@signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array | ||
@summary Creates a keccak Uint8Array from the input. | ||
@description | ||
From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`. | ||
@example | ||
import { keccakAsU8a } from '@polkadot/util-crypto'; | ||
keccakAsU8a('123') // => Uint8Array | ||
*/ | ||
* @name keccakAsU8a | ||
* @signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array | ||
* @summary Creates a keccak Uint8Array from the input. | ||
* @description | ||
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`. | ||
* @example | ||
* import { keccakAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* keccakAsU8a('123') // => Uint8Array | ||
*/ | ||
export default function keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array { | ||
@@ -20,0 +20,0 @@ return new Uint8Array( |
import keccakAsHex from './asHex'; | ||
import keccakAsU8a from './asU8a'; | ||
/** | ||
@summary Create Keccak256 values as hex & Uint8Array output | ||
*/ | ||
* @summary Create Keccak256 values as hex & Uint8Array output | ||
*/ | ||
export { keccakAsHex, keccakAsU8a }; |
@@ -9,4 +9,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Create Keccak256 values as hex & Uint8Array output | ||
*/ | ||
* @summary Create Keccak256 values as hex & Uint8Array output | ||
*/ | ||
export { | ||
@@ -13,0 +13,0 @@ keccakAsHex, |
/** | ||
@name naclDecrypt | ||
@signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | ||
@summary Decrypts a message using the supplied secretKey and nonce | ||
@description | ||
Returns an decrypted message, using the `secret` and `nonce`. | ||
@example | ||
import { naclDecrypt } from '@polkadot/util-crypto'; | ||
naclDecrypt([...], [...], [...]) // => [...] | ||
*/ | ||
* @name naclDecrypt | ||
* @signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | ||
* @summary Decrypts a message using the supplied secretKey and nonce | ||
* @description | ||
* Returns an decrypted message, using the `secret` and `nonce`. | ||
* @example | ||
* import { naclDecrypt } from '@polkadot/util-crypto'; | ||
* | ||
* naclDecrypt([...], [...], [...]) // => [...] | ||
*/ | ||
export default function naclDecrypt(encrypted: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | null; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name naclDecrypt | ||
@signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | ||
@summary Decrypts a message using the supplied secretKey and nonce | ||
@description | ||
Returns an decrypted message, using the `secret` and `nonce`. | ||
@example | ||
import { naclDecrypt } from '@polkadot/util-crypto'; | ||
naclDecrypt([...], [...], [...]) // => [...] | ||
*/ | ||
* @name naclDecrypt | ||
* @signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | ||
* @summary Decrypts a message using the supplied secretKey and nonce | ||
* @description | ||
* Returns an decrypted message, using the `secret` and `nonce`. | ||
* @example | ||
* import { naclDecrypt } from '@polkadot/util-crypto'; | ||
* | ||
* naclDecrypt([...], [...], [...]) // => [...] | ||
*/ | ||
function naclDecrypt(encrypted, nonce, secret) { | ||
return _tweetnacl.default.secretbox.open(encrypted, nonce, secret); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclDecrypt | ||
@signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | ||
@summary Decrypts a message using the supplied secretKey and nonce | ||
@description | ||
Returns an decrypted message, using the `secret` and `nonce`. | ||
@example | ||
import { naclDecrypt } from '@polkadot/util-crypto'; | ||
naclDecrypt([...], [...], [...]) // => [...] | ||
*/ | ||
* @name naclDecrypt | ||
* @signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | ||
* @summary Decrypts a message using the supplied secretKey and nonce | ||
* @description | ||
* Returns an decrypted message, using the `secret` and `nonce`. | ||
* @example | ||
* import { naclDecrypt } from '@polkadot/util-crypto'; | ||
* | ||
* naclDecrypt([...], [...], [...]) // => [...] | ||
*/ | ||
export default function naclDecrypt (encrypted: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array | null { | ||
return nacl.secretbox.open(encrypted, nonce, secret); | ||
} |
@@ -6,13 +6,13 @@ declare type Encrypted = { | ||
/** | ||
@name naclEncrypt | ||
@signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array } | ||
@summary Encrypts a message using the supplied secretKey and nonce | ||
@description | ||
Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. | ||
@example | ||
import { naclEncrypt } from '@polkadot/util-crypto'; | ||
naclSign([...], [...]) // => [...] | ||
*/ | ||
* @name naclEncrypt | ||
* @signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array } | ||
* @summary Encrypts a message using the supplied secretKey and nonce | ||
* @description | ||
* Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. | ||
* @example | ||
* import { naclEncrypt } from '@polkadot/util-crypto'; | ||
* | ||
* naclSign([...], [...]) // => [...] | ||
*/ | ||
export default function naclEncrypt(message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): Encrypted; | ||
export {}; |
@@ -19,12 +19,12 @@ "use strict"; | ||
/** | ||
@name naclEncrypt | ||
@signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array } | ||
@summary Encrypts a message using the supplied secretKey and nonce | ||
@description | ||
Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. | ||
@example | ||
import { naclEncrypt } from '@polkadot/util-crypto'; | ||
naclSign([...], [...]) // => [...] | ||
*/ | ||
* @name naclEncrypt | ||
* @signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array } | ||
* @summary Encrypts a message using the supplied secretKey and nonce | ||
* @description | ||
* Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. | ||
* @example | ||
* import { naclEncrypt } from '@polkadot/util-crypto'; | ||
* | ||
* naclSign([...], [...]) // => [...] | ||
*/ | ||
function naclEncrypt(message, secret, nonce = (0, _asU8a.default)(24)) { | ||
@@ -31,0 +31,0 @@ return { |
@@ -15,12 +15,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclEncrypt | ||
@signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array } | ||
@summary Encrypts a message using the supplied secretKey and nonce | ||
@description | ||
Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. | ||
@example | ||
import { naclEncrypt } from '@polkadot/util-crypto'; | ||
naclSign([...], [...]) // => [...] | ||
*/ | ||
* @name naclEncrypt | ||
* @signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array } | ||
* @summary Encrypts a message using the supplied secretKey and nonce | ||
* @description | ||
* Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. | ||
* @example | ||
* import { naclEncrypt } from '@polkadot/util-crypto'; | ||
* | ||
* naclSign([...], [...]) // => [...] | ||
*/ | ||
export default function naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce: Uint8Array = randomAsU8a(24)): Encrypted { | ||
@@ -27,0 +27,0 @@ return { |
@@ -10,4 +10,4 @@ import naclDecrypt from './decrypt'; | ||
/** | ||
@summary Implements [NaCl](http://nacl.cr.yp.to/) secret-key authenticated encryption, public-key authenticated encryption, hashing, and public-key signatures | ||
*/ | ||
* @summary Implements [NaCl](http://nacl.cr.yp.to/) secret-key authenticated encryption, public-key authenticated encryption, hashing, and public-key signatures | ||
*/ | ||
export { naclDecrypt, naclEncrypt, naclKeypairFromRandom, naclKeypairFromSecret, naclKeypairFromSeed, naclKeypairFromString, naclSign, naclVerify }; |
@@ -15,4 +15,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Implements [NaCl](http://nacl.cr.yp.to/) secret-key authenticated encryption, public-key authenticated encryption, hashing, and public-key signatures | ||
*/ | ||
* @summary Implements [NaCl](http://nacl.cr.yp.to/) secret-key authenticated encryption, public-key authenticated encryption, hashing, and public-key signatures | ||
*/ | ||
export { | ||
@@ -19,0 +19,0 @@ naclDecrypt, |
import { KeypairType } from '../../types'; | ||
/** | ||
@name naclKeypair | ||
@signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair. | ||
@description | ||
Returns a new generate object containing a `publicKey` & `secretKey`. | ||
@example | ||
import { naclKeypair } from '@polkadot/util-crypto'; | ||
naclKeypair() // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypair | ||
* @signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair. | ||
* @description | ||
* Returns a new generate object containing a `publicKey` & `secretKey`. | ||
* @example | ||
* import { naclKeypair } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypair() // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromRandom(): KeypairType; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name naclKeypair | ||
@signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair. | ||
@description | ||
Returns a new generate object containing a `publicKey` & `secretKey`. | ||
@example | ||
import { naclKeypair } from '@polkadot/util-crypto'; | ||
naclKeypair() // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypair | ||
* @signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair. | ||
* @description | ||
* Returns a new generate object containing a `publicKey` & `secretKey`. | ||
* @example | ||
* import { naclKeypair } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypair() // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
function naclKeypairFromRandom() { | ||
return _tweetnacl.default.sign.keyPair(); | ||
} |
@@ -10,14 +10,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclKeypair | ||
@signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair. | ||
@description | ||
Returns a new generate object containing a `publicKey` & `secretKey`. | ||
@example | ||
import { naclKeypair } from '@polkadot/util-crypto'; | ||
naclKeypair() // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypair | ||
* @signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair. | ||
* @description | ||
* Returns a new generate object containing a `publicKey` & `secretKey`. | ||
* @example | ||
* import { naclKeypair } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypair() // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromRandom (): KeypairType { | ||
return nacl.sign.keyPair(); | ||
} |
import { KeypairType } from '../../types'; | ||
/** | ||
@name naclKeypairFromSecret | ||
@signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a secret. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret. | ||
@example | ||
import { naclKeypairFromSecret } from '@polkadot/util-crypto'; | ||
naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromSecret | ||
* @signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a secret. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret. | ||
* @example | ||
* import { naclKeypairFromSecret } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromSecret(secret: Uint8Array): KeypairType; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name naclKeypairFromSecret | ||
@signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a secret. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret. | ||
@example | ||
import { naclKeypairFromSecret } from '@polkadot/util-crypto'; | ||
naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromSecret | ||
* @signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a secret. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret. | ||
* @example | ||
* import { naclKeypairFromSecret } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
function naclKeypairFromSecret(secret) { | ||
return _tweetnacl.default.sign.keyPair.fromSecretKey(secret); | ||
} |
@@ -10,14 +10,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclKeypairFromSecret | ||
@signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a secret. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret. | ||
@example | ||
import { naclKeypairFromSecret } from '@polkadot/util-crypto'; | ||
naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromSecret | ||
* @signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a secret. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret. | ||
* @example | ||
* import { naclKeypairFromSecret } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromSecret (secret: Uint8Array): KeypairType { | ||
return nacl.sign.keyPair.fromSecretKey(secret); | ||
} |
import { KeypairType } from '../../types'; | ||
/** | ||
@name naclKeypairFromSeed | ||
@signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a seed. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. | ||
@example | ||
import { naclKeypairFromSeed } from '@polkadot/util-crypto'; | ||
naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromSeed | ||
* @signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a seed. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. | ||
* @example | ||
* import { naclKeypairFromSeed } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromSeed(seed: Uint8Array): KeypairType; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name naclKeypairFromSeed | ||
@signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a seed. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. | ||
@example | ||
import { naclKeypairFromSeed } from '@polkadot/util-crypto'; | ||
naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromSeed | ||
* @signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a seed. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. | ||
* @example | ||
* import { naclKeypairFromSeed } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
function naclKeypairFromSeed(seed) { | ||
return _tweetnacl.default.sign.keyPair.fromSeed(seed); | ||
} |
@@ -10,14 +10,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclKeypairFromSeed | ||
@signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a seed. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. | ||
@example | ||
import { naclKeypairFromSeed } from '@polkadot/util-crypto'; | ||
naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromSeed | ||
* @signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a seed. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. | ||
* @example | ||
* import { naclKeypairFromSeed } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromSeed (seed: Uint8Array): KeypairType { | ||
return nacl.sign.keyPair.fromSeed(seed); | ||
} |
import { KeypairType } from '../../types'; | ||
/** | ||
@name naclKeypairFromString | ||
@signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a string. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed. | ||
@example | ||
import { naclKeypairFromString } from '@polkadot/util-crypto'; | ||
naclKeypairFromString('test') // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromString | ||
* @signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a string. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed. | ||
* @example | ||
* import { naclKeypairFromString } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromString('test') // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromString(value: string): KeypairType; |
@@ -21,14 +21,14 @@ "use strict"; | ||
/** | ||
@name naclKeypairFromString | ||
@signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a string. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed. | ||
@example | ||
import { naclKeypairFromString } from '@polkadot/util-crypto'; | ||
naclKeypairFromString('test') // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromString | ||
* @signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a string. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed. | ||
* @example | ||
* import { naclKeypairFromString } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromString('test') // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
function naclKeypairFromString(value) { | ||
return (0, _fromSeed.default)((0, _asU8a.default)((0, _fromUtf.default)(value), 256)); | ||
} |
@@ -13,12 +13,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclKeypairFromString | ||
@signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
@summary Creates a new public/secret keypair from a string. | ||
@description | ||
Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed. | ||
@example | ||
import { naclKeypairFromString } from '@polkadot/util-crypto'; | ||
naclKeypairFromString('test') // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
* @name naclKeypairFromString | ||
* @signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array } | ||
* @summary Creates a new public/secret keypair from a string. | ||
* @description | ||
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed. | ||
* @example | ||
* import { naclKeypairFromString } from '@polkadot/util-crypto'; | ||
* | ||
* naclKeypairFromString('test') // => { secretKey: [...], publicKey: [...] } | ||
*/ | ||
export default function naclKeypairFromString (value: string): KeypairType { | ||
@@ -25,0 +25,0 @@ return fromSeed( |
/** | ||
@name naclSign | ||
@signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array | ||
@summary Signs a message using the supplied secretKey | ||
@description | ||
Returns message signature of `message`, using the `secretKey`. | ||
@example | ||
import { naclSign } from '@polkadot/util-crypto'; | ||
naclSign([...], [...]) // => [...] | ||
*/ | ||
* @name naclSign | ||
* @signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array | ||
* @summary Signs a message using the supplied secretKey | ||
* @description | ||
* Returns message signature of `message`, using the `secretKey`. | ||
* @example | ||
* import { naclSign } from '@polkadot/util-crypto'; | ||
* | ||
* naclSign([...], [...]) // => [...] | ||
*/ | ||
export default function naclSign(message: Uint8Array, secretKey: Uint8Array): Uint8Array; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name naclSign | ||
@signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array | ||
@summary Signs a message using the supplied secretKey | ||
@description | ||
Returns message signature of `message`, using the `secretKey`. | ||
@example | ||
import { naclSign } from '@polkadot/util-crypto'; | ||
naclSign([...], [...]) // => [...] | ||
*/ | ||
* @name naclSign | ||
* @signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array | ||
* @summary Signs a message using the supplied secretKey | ||
* @description | ||
* Returns message signature of `message`, using the `secretKey`. | ||
* @example | ||
* import { naclSign } from '@polkadot/util-crypto'; | ||
* | ||
* naclSign([...], [...]) // => [...] | ||
*/ | ||
function naclSign(message, secretKey) { | ||
return _tweetnacl.default.sign.detached(message, secretKey); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclSign | ||
@signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array | ||
@summary Signs a message using the supplied secretKey | ||
@description | ||
Returns message signature of `message`, using the `secretKey`. | ||
@example | ||
import { naclSign } from '@polkadot/util-crypto'; | ||
naclSign([...], [...]) // => [...] | ||
*/ | ||
* @name naclSign | ||
* @signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array | ||
* @summary Signs a message using the supplied secretKey | ||
* @description | ||
* Returns message signature of `message`, using the `secretKey`. | ||
* @example | ||
* import { naclSign } from '@polkadot/util-crypto'; | ||
* | ||
* naclSign([...], [...]) // => [...] | ||
*/ | ||
export default function naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array { | ||
return nacl.sign.detached(message, secretKey); | ||
} |
/** | ||
@name naclSign | ||
@signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean | ||
@summary Verifies the signature on the supplied message. | ||
@description | ||
Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. | ||
@example | ||
import { naclVerify } from '@polkadot/util-crypto'; | ||
naclVerify([...], [...], [...]) // => true/false | ||
*/ | ||
* @name naclSign | ||
* @signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean | ||
* @summary Verifies the signature on the supplied message. | ||
* @description | ||
* Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. | ||
* @example | ||
* import { naclVerify } from '@polkadot/util-crypto'; | ||
* | ||
* naclVerify([...], [...], [...]) // => true/false | ||
*/ | ||
export default function naclVerify(message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name naclSign | ||
@signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean | ||
@summary Verifies the signature on the supplied message. | ||
@description | ||
Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. | ||
@example | ||
import { naclVerify } from '@polkadot/util-crypto'; | ||
naclVerify([...], [...], [...]) // => true/false | ||
*/ | ||
* @name naclSign | ||
* @signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean | ||
* @summary Verifies the signature on the supplied message. | ||
* @description | ||
* Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. | ||
* @example | ||
* import { naclVerify } from '@polkadot/util-crypto'; | ||
* | ||
* naclVerify([...], [...], [...]) // => true/false | ||
*/ | ||
function naclVerify(message, signature, publicKey) { | ||
return _tweetnacl.default.sign.detached.verify(message, signature, publicKey); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name naclSign | ||
@signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean | ||
@summary Verifies the signature on the supplied message. | ||
@description | ||
Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. | ||
@example | ||
import { naclVerify } from '@polkadot/util-crypto'; | ||
naclVerify([...], [...], [...]) // => true/false | ||
*/ | ||
* @name naclSign | ||
* @signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean | ||
* @summary Verifies the signature on the supplied message. | ||
* @description | ||
* Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. | ||
* @example | ||
* import { naclVerify } from '@polkadot/util-crypto'; | ||
* | ||
* naclVerify([...], [...], [...]) // => true/false | ||
*/ | ||
export default function naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean { | ||
return nacl.sign.detached.verify(message, signature, publicKey); | ||
} |
{ | ||
"name": "@polkadot/util-crypto", | ||
"version": "0.25.1", | ||
"version": "0.26.5", | ||
"description": "A collection of useful crypto utilities for @polkadot", | ||
@@ -37,3 +37,3 @@ "main": "index.js", | ||
"@babel/runtime": "^7.0.0-beta.51", | ||
"@polkadot/util": "^0.25.1", | ||
"@polkadot/util": "^0.26.5", | ||
"blakejs": "^1.1.0", | ||
@@ -40,0 +40,0 @@ "js-sha3": "^0.7.0", |
/** | ||
@name randomAsHex | ||
@signature randomAsHex (length?: number = 32): string | ||
@summary Creates a hex string filled with random bytes. | ||
@description | ||
Returns a hex string with the specified (optional) length filled with random bytes. | ||
@example | ||
import { randomAsHex } from '@polkadot/util-crypto'; | ||
randomAsHex() // => 0x... | ||
*/ | ||
* @name randomAsHex | ||
* @signature randomAsHex (length?: number = 32): string | ||
* @summary Creates a hex string filled with random bytes. | ||
* @description | ||
* Returns a hex string with the specified (optional) length filled with random bytes. | ||
* @example | ||
* import { randomAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsHex() // => 0x... | ||
*/ | ||
export default function randomAsHex(length?: number): string; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name randomAsHex | ||
@signature randomAsHex (length?: number = 32): string | ||
@summary Creates a hex string filled with random bytes. | ||
@description | ||
Returns a hex string with the specified (optional) length filled with random bytes. | ||
@example | ||
import { randomAsHex } from '@polkadot/util-crypto'; | ||
randomAsHex() // => 0x... | ||
*/ | ||
* @name randomAsHex | ||
* @signature randomAsHex (length?: number = 32): string | ||
* @summary Creates a hex string filled with random bytes. | ||
* @description | ||
* Returns a hex string with the specified (optional) length filled with random bytes. | ||
* @example | ||
* import { randomAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsHex() // => 0x... | ||
*/ | ||
function randomAsHex(length = 32) { | ||
return (0, _toHex.default)((0, _asU8a.default)(length)); | ||
} |
@@ -10,12 +10,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name randomAsHex | ||
@signature randomAsHex (length?: number = 32): string | ||
@summary Creates a hex string filled with random bytes. | ||
@description | ||
Returns a hex string with the specified (optional) length filled with random bytes. | ||
@example | ||
import { randomAsHex } from '@polkadot/util-crypto'; | ||
randomAsHex() // => 0x... | ||
*/ | ||
* @name randomAsHex | ||
* @signature randomAsHex (length?: number = 32): string | ||
* @summary Creates a hex string filled with random bytes. | ||
* @description | ||
* Returns a hex string with the specified (optional) length filled with random bytes. | ||
* @example | ||
* import { randomAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsHex() // => 0x... | ||
*/ | ||
export default function randomAsHex (length: number = 32): string { | ||
@@ -22,0 +22,0 @@ return u8aToHex( |
/** | ||
@name randomAsNumber | ||
@signature randomAsNumber (): number | ||
@summary Creates a random number from random bytes. | ||
@description | ||
Returns a random number generated from the secure bytes. | ||
@example | ||
import { randomAsNumber } from '@polkadot/util-crypto'; | ||
randomAsNumber() // => <random number> | ||
*/ | ||
* @name randomAsNumber | ||
* @signature randomAsNumber (): number | ||
* @summary Creates a random number from random bytes. | ||
* @description | ||
* Returns a random number generated from the secure bytes. | ||
* @example | ||
* import { randomAsNumber } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsNumber() // => <random number> | ||
*/ | ||
export default function randomAsNumber(): number; |
@@ -21,15 +21,15 @@ "use strict"; | ||
/** | ||
@name randomAsNumber | ||
@signature randomAsNumber (): number | ||
@summary Creates a random number from random bytes. | ||
@description | ||
Returns a random number generated from the secure bytes. | ||
@example | ||
import { randomAsNumber } from '@polkadot/util-crypto'; | ||
* @name randomAsNumber | ||
* @signature randomAsNumber (): number | ||
* @summary Creates a random number from random bytes. | ||
* @description | ||
* Returns a random number generated from the secure bytes. | ||
* @example | ||
* import { randomAsNumber } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsNumber() // => <random number> | ||
*/ | ||
randomAsNumber() // => <random number> | ||
*/ | ||
function randomAsNumber() { | ||
return (0, _toBn.default)((0, _asHex.default)(8)).and(BN_53).toNumber(); | ||
} |
@@ -13,12 +13,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name randomAsNumber | ||
@signature randomAsNumber (): number | ||
@summary Creates a random number from random bytes. | ||
@description | ||
Returns a random number generated from the secure bytes. | ||
@example | ||
import { randomAsNumber } from '@polkadot/util-crypto'; | ||
randomAsNumber() // => <random number> | ||
*/ | ||
* @name randomAsNumber | ||
* @signature randomAsNumber (): number | ||
* @summary Creates a random number from random bytes. | ||
* @description | ||
* Returns a random number generated from the secure bytes. | ||
* @example | ||
* import { randomAsNumber } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsNumber() // => <random number> | ||
*/ | ||
export default function randomAsNumber (): number { | ||
@@ -25,0 +25,0 @@ return hexToBn( |
/** | ||
@name randomAsU8a | ||
@signature randomAsU8a (length?: number = 32): Uint8Array | ||
@summary Creates a Uint8Array filled with random bytes. | ||
@description | ||
Returns a `Uint8Array` with the specified (optional) length filled with random bytes. | ||
@example | ||
import { randomAsU8a } from '@polkadot/util-crypto'; | ||
randomAsU8s() // => Uint8Array([...]) | ||
*/ | ||
* @name randomAsU8a | ||
* @signature randomAsU8a (length?: number = 32): Uint8Array | ||
* @summary Creates a Uint8Array filled with random bytes. | ||
* @description | ||
* Returns a `Uint8Array` with the specified (optional) length filled with random bytes. | ||
* @example | ||
* import { randomAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsU8s() // => Uint8Array([...]) | ||
*/ | ||
export default function randomAsU8a(length?: number): Uint8Array; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name randomAsU8a | ||
@signature randomAsU8a (length?: number = 32): Uint8Array | ||
@summary Creates a Uint8Array filled with random bytes. | ||
@description | ||
Returns a `Uint8Array` with the specified (optional) length filled with random bytes. | ||
@example | ||
import { randomAsU8a } from '@polkadot/util-crypto'; | ||
randomAsU8s() // => Uint8Array([...]) | ||
*/ | ||
* @name randomAsU8a | ||
* @signature randomAsU8a (length?: number = 32): Uint8Array | ||
* @summary Creates a Uint8Array filled with random bytes. | ||
* @description | ||
* Returns a `Uint8Array` with the specified (optional) length filled with random bytes. | ||
* @example | ||
* import { randomAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsU8s() // => Uint8Array([...]) | ||
*/ | ||
function randomAsU8a(length = 32) { | ||
return _tweetnacl.default.randomBytes(length); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name randomAsU8a | ||
@signature randomAsU8a (length?: number = 32): Uint8Array | ||
@summary Creates a Uint8Array filled with random bytes. | ||
@description | ||
Returns a `Uint8Array` with the specified (optional) length filled with random bytes. | ||
@example | ||
import { randomAsU8a } from '@polkadot/util-crypto'; | ||
randomAsU8s() // => Uint8Array([...]) | ||
*/ | ||
* @name randomAsU8a | ||
* @signature randomAsU8a (length?: number = 32): Uint8Array | ||
* @summary Creates a Uint8Array filled with random bytes. | ||
* @description | ||
* Returns a `Uint8Array` with the specified (optional) length filled with random bytes. | ||
* @example | ||
* import { randomAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* randomAsU8s() // => Uint8Array([...]) | ||
*/ | ||
export default function randomAsU8a (length: number = 32): Uint8Array { | ||
return nacl.randomBytes(length); | ||
} |
@@ -5,4 +5,4 @@ import randomAsHex from './asHex'; | ||
/** | ||
@summary Returns a sequence of secure random bytes in a variety of formats | ||
*/ | ||
* @summary Returns a sequence of secure random bytes in a variety of formats | ||
*/ | ||
export { randomAsHex, randomAsNumber, randomAsU8a }; |
@@ -10,4 +10,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Returns a sequence of secure random bytes in a variety of formats | ||
*/ | ||
* @summary Returns a sequence of secure random bytes in a variety of formats | ||
*/ | ||
export { | ||
@@ -14,0 +14,0 @@ randomAsHex, |
/** | ||
@name sha512AsU8a | ||
@signature sha512AsU8a (data: Uint8Array): Uint8Array | ||
@summary Creates sha-512 hash of the input. | ||
@description | ||
Returns a sha-512 `Uint8Array` from the supplied data. | ||
@example | ||
import { sha512AsU8a } from '@polkadot/util-crypto'; | ||
sha512AsU8a(Uint8Array.from([...])) // => Uint8Array([...]) | ||
*/ | ||
* @name sha512AsU8a | ||
* @signature sha512AsU8a (data: Uint8Array): Uint8Array | ||
* @summary Creates sha-512 hash of the input. | ||
* @description | ||
* Returns a sha-512 `Uint8Array` from the supplied data. | ||
* @example | ||
* import { sha512AsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* sha512AsU8a(Uint8Array.from([...])) // => Uint8Array([...]) | ||
*/ | ||
export default function sha512AsU8a(data: Uint8Array): Uint8Array; |
@@ -17,14 +17,14 @@ "use strict"; | ||
/** | ||
@name sha512AsU8a | ||
@signature sha512AsU8a (data: Uint8Array): Uint8Array | ||
@summary Creates sha-512 hash of the input. | ||
@description | ||
Returns a sha-512 `Uint8Array` from the supplied data. | ||
@example | ||
import { sha512AsU8a } from '@polkadot/util-crypto'; | ||
sha512AsU8a(Uint8Array.from([...])) // => Uint8Array([...]) | ||
*/ | ||
* @name sha512AsU8a | ||
* @signature sha512AsU8a (data: Uint8Array): Uint8Array | ||
* @summary Creates sha-512 hash of the input. | ||
* @description | ||
* Returns a sha-512 `Uint8Array` from the supplied data. | ||
* @example | ||
* import { sha512AsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* sha512AsU8a(Uint8Array.from([...])) // => Uint8Array([...]) | ||
*/ | ||
function sha512AsU8a(data) { | ||
return _tweetnacl.default.hash(data); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name sha512AsU8a | ||
@signature sha512AsU8a (data: Uint8Array): Uint8Array | ||
@summary Creates sha-512 hash of the input. | ||
@description | ||
Returns a sha-512 `Uint8Array` from the supplied data. | ||
@example | ||
import { sha512AsU8a } from '@polkadot/util-crypto'; | ||
sha512AsU8a(Uint8Array.from([...])) // => Uint8Array([...]) | ||
*/ | ||
* @name sha512AsU8a | ||
* @signature sha512AsU8a (data: Uint8Array): Uint8Array | ||
* @summary Creates sha-512 hash of the input. | ||
* @description | ||
* Returns a sha-512 `Uint8Array` from the supplied data. | ||
* @example | ||
* import { sha512AsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* sha512AsU8a(Uint8Array.from([...])) // => Uint8Array([...]) | ||
*/ | ||
export default function sha512AsU8a (data: Uint8Array): Uint8Array { | ||
return nacl.hash(data); | ||
} |
import sha512AsU8a from './asU8a'; | ||
/** | ||
@summary Implements Sha-512 hashing functions for a variety of input and outputs | ||
*/ | ||
* @summary Implements Sha-512 hashing functions for a variety of input and outputs | ||
*/ | ||
export { sha512AsU8a }; |
@@ -8,6 +8,6 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Implements Sha-512 hashing functions for a variety of input and outputs | ||
*/ | ||
* @summary Implements Sha-512 hashing functions for a variety of input and outputs | ||
*/ | ||
export { | ||
sha512AsU8a | ||
}; |
/// <reference types="node" /> | ||
/** | ||
@name xxhashAsHex | ||
@signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLenght: number = 64): string | ||
@summary Creates a xxhash64 hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`. | ||
@example | ||
import { xxhashAsHex } from '@polkadot/util-crypto'; | ||
xxhashAsHex('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
* @name xxhashAsHex | ||
* @signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLenght: number = 64): string | ||
* @summary Creates a xxhash64 hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`. | ||
* @example | ||
* import { xxhashAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* xxhashAsHex('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
export default function xxhashAsHex(data: Buffer | Uint8Array | string, bitLength?: number): string; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name xxhashAsHex | ||
@signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLenght: number = 64): string | ||
@summary Creates a xxhash64 hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`. | ||
@example | ||
import { xxhashAsHex } from '@polkadot/util-crypto'; | ||
xxhashAsHex('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
* @name xxhashAsHex | ||
* @signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLenght: number = 64): string | ||
* @summary Creates a xxhash64 hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`. | ||
* @example | ||
* import { xxhashAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* xxhashAsHex('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
function xxhashAsHex(data, bitLength = 64) { | ||
return (0, _toHex.default)((0, _asU8a.default)(data, bitLength)); | ||
} |
@@ -10,12 +10,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name xxhashAsHex | ||
@signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLenght: number = 64): string | ||
@summary Creates a xxhash64 hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`. | ||
@example | ||
import { xxhashAsHex } from '@polkadot/util-crypto'; | ||
xxhashAsHex('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
* @name xxhashAsHex | ||
* @signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLenght: number = 64): string | ||
* @summary Creates a xxhash64 hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`. | ||
* @example | ||
* import { xxhashAsHex } from '@polkadot/util-crypto'; | ||
* | ||
* xxhashAsHex('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
export default function xxhashAsHex (data: Buffer | Uint8Array | string, bitLength: number = 64): string { | ||
@@ -22,0 +22,0 @@ return u8aToHex( |
/// <reference types="node" /> | ||
/** | ||
@name xxhashAsU8a | ||
@signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLenght: number = 64): Uint8Array | ||
@summary Creates a xxhash64 u8a from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. | ||
@example | ||
import { xxhashAsU8a } from '@polkadot/util-crypto'; | ||
xxhashAsU8a('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
* @name xxhashAsU8a | ||
* @signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLenght: number = 64): Uint8Array | ||
* @summary Creates a xxhash64 u8a from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. | ||
* @example | ||
* import { xxhashAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* xxhashAsU8a('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
export default function xxhashAsU8a(data: Buffer | Uint8Array | string, bitLength?: number): Uint8Array; |
@@ -17,12 +17,12 @@ "use strict"; | ||
/** | ||
@name xxhashAsU8a | ||
@signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLenght: number = 64): Uint8Array | ||
@summary Creates a xxhash64 u8a from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. | ||
@example | ||
import { xxhashAsU8a } from '@polkadot/util-crypto'; | ||
xxhashAsU8a('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
* @name xxhashAsU8a | ||
* @signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLenght: number = 64): Uint8Array | ||
* @summary Creates a xxhash64 u8a from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. | ||
* @example | ||
* import { xxhashAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* xxhashAsU8a('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
function xxhashAsU8a(data, bitLength = 64) { | ||
@@ -29,0 +29,0 @@ const byteLength = Math.ceil(bitLength / 8); |
@@ -8,12 +8,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name xxhashAsU8a | ||
@signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLenght: number = 64): Uint8Array | ||
@summary Creates a xxhash64 u8a from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. | ||
@example | ||
import { xxhashAsU8a } from '@polkadot/util-crypto'; | ||
xxhashAsU8a('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
* @name xxhashAsU8a | ||
* @signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLenght: number = 64): Uint8Array | ||
* @summary Creates a xxhash64 u8a from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`. | ||
* @example | ||
* import { xxhashAsU8a } from '@polkadot/util-crypto'; | ||
* | ||
* xxhashAsU8a('abc') // => 0x44bc2cf5ad770999 | ||
*/ | ||
export default function xxhashAsU8a (data: Buffer | Uint8Array | string, bitLength: number = 64): Uint8Array { | ||
@@ -20,0 +20,0 @@ const byteLength = Math.ceil(bitLength / 8); |
import xxhashAsHex from './asHex'; | ||
import xxhashAsU8a from './asU8a'; | ||
/** | ||
@summary Create xxhash64 values with specified bitlengths | ||
*/ | ||
* @summary Create xxhash64 values with specified bitlengths | ||
*/ | ||
export { xxhashAsHex, xxhashAsU8a }; |
@@ -9,4 +9,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Create xxhash64 values with specified bitlengths | ||
*/ | ||
* @summary Create xxhash64 values with specified bitlengths | ||
*/ | ||
export { | ||
@@ -13,0 +13,0 @@ xxhashAsHex, |
/// <reference types="node" /> | ||
import BN from 'bn.js'; | ||
/** | ||
@name xxhash64AsBn | ||
@signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN | ||
@summary Creates a xxhash BN from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. | ||
@example | ||
import { xxhash64AsNumber } from '@polkadot/util-crypto'; | ||
xxhash64AsBn('abcd', 0xabcd)) // => new BN(0xe29f70f8b8c96df7) | ||
*/ | ||
* @name xxhash64AsBn | ||
* @signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN | ||
* @summary Creates a xxhash BN from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. | ||
* @example | ||
* import { xxhash64AsNumber } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsBn('abcd', 0xabcd)) // => new BN(0xe29f70f8b8c96df7) | ||
*/ | ||
export default function xxhash64AsBn(data: Buffer | Uint8Array | string, seed: number): BN; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name xxhash64AsBn | ||
@signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN | ||
@summary Creates a xxhash BN from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. | ||
@example | ||
import { xxhash64AsNumber } from '@polkadot/util-crypto'; | ||
xxhash64AsBn('abcd', 0xabcd)) // => new BN(0xe29f70f8b8c96df7) | ||
*/ | ||
* @name xxhash64AsBn | ||
* @signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN | ||
* @summary Creates a xxhash BN from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. | ||
* @example | ||
* import { xxhash64AsNumber } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsBn('abcd', 0xabcd)) // => new BN(0xe29f70f8b8c96df7) | ||
*/ | ||
function xxhash64AsBn(data, seed) { | ||
return new _bn.default((0, _asRaw.default)(data, seed), 16); | ||
} |
@@ -10,12 +10,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name xxhash64AsBn | ||
@signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN | ||
@summary Creates a xxhash BN from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. | ||
@example | ||
import { xxhash64AsNumber } from '@polkadot/util-crypto'; | ||
xxhash64AsBn('abcd', 0xabcd)) // => new BN(0xe29f70f8b8c96df7) | ||
*/ | ||
* @name xxhash64AsBn | ||
* @signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN | ||
* @summary Creates a xxhash BN from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN. | ||
* @example | ||
* import { xxhash64AsNumber } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsBn('abcd', 0xabcd)) // => new BN(0xe29f70f8b8c96df7) | ||
*/ | ||
export default function xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN { | ||
@@ -22,0 +22,0 @@ return new BN( |
/// <reference types="node" /> | ||
/** | ||
@name xxhash64AsHex | ||
@signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string | ||
@summary Creates a xxhash hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string. | ||
@example | ||
import { xxhash64AsHex } from '@polkadot/util-crypto'; | ||
xxhash64AsHex('abcd', 0xabcd)) // => 0xe29f70f8b8c96df7 | ||
*/ | ||
* @name xxhash64AsHex | ||
* @signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string | ||
* @summary Creates a xxhash hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string. | ||
* @example | ||
* import { xxhash64AsHex } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsHex('abcd', 0xabcd)) // => 0xe29f70f8b8c96df7 | ||
*/ | ||
export default function xxhash64AsHex(data: Buffer | Uint8Array | string, seed: number): string; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name xxhash64AsHex | ||
@signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string | ||
@summary Creates a xxhash hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string. | ||
@example | ||
import { xxhash64AsHex } from '@polkadot/util-crypto'; | ||
xxhash64AsHex('abcd', 0xabcd)) // => 0xe29f70f8b8c96df7 | ||
*/ | ||
* @name xxhash64AsHex | ||
* @signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string | ||
* @summary Creates a xxhash hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string. | ||
* @example | ||
* import { xxhash64AsHex } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsHex('abcd', 0xabcd)) // => 0xe29f70f8b8c96df7 | ||
*/ | ||
function xxhash64AsHex(data, seed) { | ||
return (0, _addPrefix.default)((0, _asRaw.default)(data, seed)); | ||
} |
@@ -10,12 +10,12 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name xxhash64AsHex | ||
@signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string | ||
@summary Creates a xxhash hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string. | ||
@example | ||
import { xxhash64AsHex } from '@polkadot/util-crypto'; | ||
xxhash64AsHex('abcd', 0xabcd)) // => 0xe29f70f8b8c96df7 | ||
*/ | ||
* @name xxhash64AsHex | ||
* @signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string | ||
* @summary Creates a xxhash hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string. | ||
* @example | ||
* import { xxhash64AsHex } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsHex('abcd', 0xabcd)) // => 0xe29f70f8b8c96df7 | ||
*/ | ||
export default function xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string { | ||
@@ -22,0 +22,0 @@ return hexAddPrefix( |
/// <reference types="node" /> | ||
/** | ||
@name xxhash64AsRaw | ||
@signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string | ||
@summary Creates a xxhash non-prefixed hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. | ||
@example | ||
import { xxhash64AsRaw } from '@polkadot/util-crypto'; | ||
xxhash64AsRaw('abcd', 0xabcd)) // => e29f70f8b8c96df7 | ||
*/ | ||
* @name xxhash64AsRaw | ||
* @signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string | ||
* @summary Creates a xxhash non-prefixed hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. | ||
* @example | ||
* import { xxhash64AsRaw } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsRaw('abcd', 0xabcd)) // => e29f70f8b8c96df7 | ||
*/ | ||
export default function xxhash64AsRaw(data: Buffer | Uint8Array | string, seed: number): string; |
@@ -19,14 +19,14 @@ "use strict"; | ||
/** | ||
@name xxhash64AsRaw | ||
@signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string | ||
@summary Creates a xxhash non-prefixed hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. | ||
@example | ||
import { xxhash64AsRaw } from '@polkadot/util-crypto'; | ||
xxhash64AsRaw('abcd', 0xabcd)) // => e29f70f8b8c96df7 | ||
*/ | ||
* @name xxhash64AsRaw | ||
* @signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string | ||
* @summary Creates a xxhash non-prefixed hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. | ||
* @example | ||
* import { xxhash64AsRaw } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsRaw('abcd', 0xabcd)) // => e29f70f8b8c96df7 | ||
*/ | ||
function xxhash64AsRaw(data, seed) { | ||
return (0, _asValue.default)(data, seed).toString(16); | ||
} |
@@ -8,14 +8,14 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@name xxhash64AsRaw | ||
@signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string | ||
@summary Creates a xxhash non-prefixed hex from the input. | ||
@description | ||
From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. | ||
@example | ||
import { xxhash64AsRaw } from '@polkadot/util-crypto'; | ||
xxhash64AsRaw('abcd', 0xabcd)) // => e29f70f8b8c96df7 | ||
*/ | ||
* @name xxhash64AsRaw | ||
* @signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string | ||
* @summary Creates a xxhash non-prefixed hex from the input. | ||
* @description | ||
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string. | ||
* @example | ||
* import { xxhash64AsRaw } from '@polkadot/util-crypto'; | ||
* | ||
* xxhash64AsRaw('abcd', 0xabcd)) // => e29f70f8b8c96df7 | ||
*/ | ||
export default function xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string { | ||
return xxhash64AsValue(data, seed).toString(16); | ||
} |
@@ -5,4 +5,4 @@ import xxhash64AsBn from './asBn'; | ||
/** | ||
@summary Create [XXHash](http://cyan4973.github.io/xxHash/) values as BN, hex & number output | ||
*/ | ||
* @summary Create [XXHash](http://cyan4973.github.io/xxHash/) values as BN, hex & number output | ||
*/ | ||
export { xxhash64AsBn, xxhash64AsHex, xxhash64AsRaw }; |
@@ -10,4 +10,4 @@ // Copyright 2017-2018 @polkadot/util-crypto authors & contributors | ||
/** | ||
@summary Create [XXHash](http://cyan4973.github.io/xxHash/) values as BN, hex & number output | ||
*/ | ||
* @summary Create [XXHash](http://cyan4973.github.io/xxHash/) values as BN, hex & number output | ||
*/ | ||
export { | ||
@@ -14,0 +14,0 @@ xxhash64AsBn, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95608
2330
+ Added@polkadot/util@0.26.36(transitive)
+ Added@types/bn.js@4.11.6(transitive)
+ Added@types/node@22.10.2(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@polkadot/util@0.25.1(transitive)
Updated@polkadot/util@^0.26.5