Gathering detailed insights and metrics for bech32-buffer
Gathering detailed insights and metrics for bech32-buffer
Gathering detailed insights and metrics for bech32-buffer
Gathering detailed insights and metrics for bech32-buffer
@cmdcode/buff
A swiss-army-knife of byte manipulation.
@cmdcode/buff-utils
Cross-platform library for working with buffers and moving between formats.
@cmdcode/bytes-utils
Cross-platform utility library for working with byte-arrays and moving between formats.
buff-commonjs
Cross-platform utility library for working with byte-arrays and moving between formats.
npm install bech32-buffer
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (91.95%)
TypeScript (5.6%)
Shell (2.45%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
22 Stars
284 Commits
11 Forks
2 Watchers
4 Branches
3 Contributors
Updated on Apr 19, 2025
Latest Version
0.2.1
Package Id
bech32-buffer@0.2.1
Unpacked Size
121.95 kB
Size
31.64 kB
File Count
11
NPM Version
8.11.0
Node Version
16.13.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
30
Bech32 is a Bitcoin address format specified in BIP 173 and BIP 350. Among its advantages are: better adaptability to QR codes and in voice conversations, and improved error detection. This library generalizes Bech32 and its modified version (Bech32m) to encode any reasonably short byte buffers.
1declare function encode( 2 prefix: string, 3 data: Uint8Array, 4 encoding: 'bech32' | 'bech32m' = 'bech32' 5): string;
Encodes binary data
with the specified human-readable prefix
into a Bech32(m) string.
The case is preserved: if the prefix is uppercase, then the output will be uppercase
as well; otherwise, the output will be lowercase (including the case when the prefix does
not contain any letters).
bech32
or bech32m
String containing:
prefix
'1'
separator chardata
encoded with the variant of base32 encoding used by Bech32, andprefix
and data
1const bech32 = require('bech32-buffer'); 2const data = new Uint8Array(20); 3bech32.encode('test', data); 4// 'test1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqql6aptf'
1declare function decode(message: string): { 2 prefix: string, 3 encoding: 'bech32' | 'bech32m', 4 data: Uint8Array 5};
Extracts human-readable prefix and binary data from the Bech32-encoded string.
An object with the following fields:
bech32
or bech32m
Decoding may fail for a variety of reasons (e.g., invalid checksum, or invalid
chars in the input). In this case, decode()
throws an exception
with a descriptive message.
1const bech32 = require('bech32-buffer'); 2const data = 'lost1qsyq7yqh9gk0szs5'; 3bech32.decode(data); 4// { 5// prefix: 'lost', 6// encoding: 'bech32', 7// data: Uint8Array([ 4, 8, 15, 16, 23, 42 ]) 8// }
1declare class BitcoinAddress { 2 prefix: 'bc' | 'tb'; 3 scriptVersion: number; 4 data: Uint8Array; 5 6 static decode(message: string): BitcoinAddress; 7 constructor(prefix: 'bc' | 'tb', scriptVersion: number, data: Uint8Array); 8 encode(): string; 9 type(): void | 'p2wsh' | 'p2wpkh'; 10}
Provides basic functionality to work with Bech32 encoding of Bitcoin addresses.
Addresses can be decode
d from strings and encode
d into strings.
It is also possible to check the type
of an address. P2WSH and P2WPKH address
types are defined per BIP 141. Encoding constraints are defined per BIP 173
and BIP 350.
1const { BitcoinAddress } = require('bech32-buffer'); 2const address = BitcoinAddress.decode('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4'); 3// address.prefix === 'bc' 4// address.scriptVersion === 0 5// address.data.length === 20 6// address.type() === 'p2wpkh'
Use dist/bech32-buffer.min.js
from the package distribution
or your favorite browserifier. In the first case,
the library will be available as a bech32
global variable:
1<script src="bech32-buffer.min.js"></script> 2<!-- later --> 3<script> 4bech32.encode('test', new Uint8Array(20)); 5</script>
Check out the web demo to see how
bech32-buffer works in browser. It is also available in the examples
directory of the package.
BIP 173 is authored by Pieter Wuille and Greg Maxwell and is licensed under the 2-clause BSD license. BIP 350 is authored by Pieter Wuille and is licensed under the 2-clause BSD license.
There are at least 2 existing implementations of Bech32 for JavaScript:
bech32
packageBoth implementations are Bitcoin-specific, and the reference implementation is also not in the Npm / yarn package manager.
bech32-buffer is available under Apache-2.0 license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More