Beta 7 with some repo names changed.
This commit is contained in:
1 parent
0f7b40cca7
commit
963c19493a
3408 files changed
+462217
-15516
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
|
||||
var base58 = require('bs58')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
module.exports = function (checksumFn) {
|
||||
// Encode a buffer as a base58-check encoded string
|
||||
function encode (payload) {
|
||||
var checksum = checksumFn(payload)
|
||||
|
||||
return base58.encode(Buffer.concat([
|
||||
payload,
|
||||
checksum
|
||||
], payload.length + 4))
|
||||
}
|
||||
|
||||
function decodeRaw (buffer) {
|
||||
var payload = buffer.slice(0, -4)
|
||||
var checksum = buffer.slice(-4)
|
||||
var newChecksum = checksumFn(payload)
|
||||
|
||||
if (checksum[0] ^ newChecksum[0] |
|
||||
checksum[1] ^ newChecksum[1] |
|
||||
checksum[2] ^ newChecksum[2] |
|
||||
checksum[3] ^ newChecksum[3]) return
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
// Decode a base58-check encoded string to a buffer, no result if checksum is wrong
|
||||
function decodeUnsafe (string) {
|
||||
var buffer = base58.decodeUnsafe(string)
|
||||
if (!buffer) return
|
||||
|
||||
return decodeRaw(buffer)
|
||||
}
|
||||
|
||||
function decode (string) {
|
||||
var buffer = base58.decode(string)
|
||||
var payload = decodeRaw(buffer, checksumFn)
|
||||
if (!payload) throw new Error('Invalid checksum')
|
||||
return payload
|
||||
}
|
||||
|
||||
return {
|
||||
encode: encode,
|
||||
decode: decode,
|
||||
decodeUnsafe: decodeUnsafe
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
var createHash = require('create-hash')
|
||||
var bs58checkBase = require('./base')
|
||||
|
||||
// SHA256(SHA256(buffer))
|
||||
function sha256x2 (buffer) {
|
||||
var tmp = createHash('sha256').update(buffer).digest()
|
||||
return createHash('sha256').update(tmp).digest()
|
||||
}
|
||||
|
||||
module.exports = bs58checkBase(sha256x2)
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "bs58check@^2.1.2",
|
||||
"_id": "bs58check@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==",
|
||||
"_location": "/bs58check",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "bs58check@^2.1.2",
|
||||
"name": "bs58check",
|
||||
"escapedName": "bs58check",
|
||||
"rawSpec": "^2.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/ethereum-cryptography"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz",
|
||||
"_shasum": "53b018291228d82a5aa08e7d796fdafda54aebfc",
|
||||
"_spec": "bs58check@^2.1.2",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\BackendServers\\node_modules\\ethereum-cryptography",
|
||||
"author": {
|
||||
"name": "Daniel Cousens"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/bitcoinjs/bs58check/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"bs58": "^4.0.0",
|
||||
"create-hash": "^1.1.0",
|
||||
"safe-buffer": "^5.1.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A straightforward implementation of base58-check encoding",
|
||||
"devDependencies": {
|
||||
"blake-hash": "^1.0.0",
|
||||
"nyc": "^11.3.0",
|
||||
"standard": "^10.0.3",
|
||||
"tape": "^4.6.2"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"base.js"
|
||||
],
|
||||
"homepage": "https://github.com/bitcoinjs/bs58check",
|
||||
"keywords": [
|
||||
"base",
|
||||
"base58",
|
||||
"base58check",
|
||||
"bitcoin",
|
||||
"bs58",
|
||||
"check",
|
||||
"checksum",
|
||||
"decode",
|
||||
"decoding",
|
||||
"encode",
|
||||
"encoding",
|
||||
"litecoin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "bs58check",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/bitcoinjs/bs58check.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc --check-coverage --branches 90 --functions 90 npm run unit",
|
||||
"coverage-report": "nyc report --reporter=lcov",
|
||||
"standard": "standard",
|
||||
"test": "npm run standard && npm run coverage",
|
||||
"unit": "tape test/*.js"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
}
|
||||
Reference in new issue
Block a user