sunknudsen
sunknudsen

Reputation: 7240

Why is base58("foobar") not equal to base58("foo") + base58("bar")?

import { encode } from "bs58"

const foobar = Buffer.from("foobar")

console.log(foobar, encode(foobar))
// <Buffer 66 6f 6f 62 61 72> t1Zv2yaZ

const foo = Buffer.from("foo")
const bar = Buffer.from("bar")

console.log(Buffer.concat([foo, bar]), `${encode(foo)}${encode(bar)}`)
// <Buffer 66 6f 6f 62 61 72> bQbpa3cM

I don’t understand why buffers are identical but output from base58 is different.

Upvotes: 0

Views: 80

Answers (0)

Related Questions