object Base58 extends BaseEncoding
Base58 is a way to encode Bitcoin addresses (or arbitrary data) as alphanumeric strings.
Note that this is not the same base58 as used by Flickr, which you may find referenced around the Internet.
You may want to consider working with PrefixedChecksummedBytes
instead, which
adds support for testing the prefix and suffix bytes commonly found in addresses.
Satoshi explains: why base-58 instead of standard base-64 encoding?
- Don't want 0OIl characters that look the same in some fonts and could be used to create visually identical looking account numbers.
- A string with non-alphanumeric characters is not as easily accepted as an account number.
- E-mail usually won't line-break if there's no punctuation to break at.
- Doubleclicking selects the whole number as one word if it's all alphanumeric.
However, note that the encoding/decoding runs in O(n²) time, so it is not useful for large data.
The basic idea of the encoding is to treat the data bytes as a large number represented using base-256 digits, convert the number to be represented using base-58 digits, preserve the exact number of leading zeros (which are otherwise lost during the mathematical operations on the numbers), and finally represent the resulting base-58 digits as alphanumeric ASCII characters.
- Source
- Base58.scala
- Alphabetic
- By Inheritance
- Base58
- BaseEncoding
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def decode(input: CharSequence): Array[Byte]
Decodes the given base58 string into the original data bytes.
Decodes the given base58 string into the original data bytes.
- input
the base58-encoded string to decode
- returns
the decoded data bytes
- Definition Classes
- Base58 → BaseEncoding
- def decode(input: Array[Char]): Array[Byte]
- Definition Classes
- Base58 → BaseEncoding
- def decodeChecked(input: String): Array[Byte]
Decodes the given base58 string into the original data bytes, using the checksum in the last 4 bytes of the decoded data to verify that the rest are correct.
Decodes the given base58 string into the original data bytes, using the checksum in the last 4 bytes of the decoded data to verify that the rest are correct. The checksum is removed from the returned data.
- input
the base58-encoded string to decode (which should include the checksum)
- def encode(input: Array[Byte]): String
Encodes the given bytes as a base58 string (no checksum is appended).
Encodes the given bytes as a base58 string (no checksum is appended).
- input
the bytes to encode
- returns
the base58-encoded string
- Definition Classes
- Base58 → BaseEncoding
- def encode(bytes: Array[Byte], offset: Int, length: Int): String
- Definition Classes
- Base58 → BaseEncoding
- def encodeChecked(payload: Array[Byte]): String
Encodes the given version and bytes as a base58 string.
Encodes the given version and bytes as a base58 string. A checksum is appended.
Note: This assumes you have already pre-pended the version byte (if applicable)
- payload
the bytes to encode, e.g. pubkey hash
- returns
the base58-encoded string
- def encodeChecked(version: Int, payload: Array[Byte]): String
Encodes the given version and bytes as a base58 string.
Encodes the given version and bytes as a base58 string. A checksum is appended.
- version
the version to encode
- payload
the bytes to encode, e.g. pubkey hash
- returns
the base58-encoded string
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def exceptionHandler: PartialFunction[Throwable, Nothing]
- Attributes
- protected
- Definition Classes
- BaseEncoding
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isLower(data: CharSequence): Boolean
- Attributes
- protected
- Definition Classes
- BaseEncoding
- def isLower(data: Array[Char]): Boolean
- Attributes
- protected
- Definition Classes
- BaseEncoding
- def main(args: Array[String]): Unit
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def tryDecode(data: CharSequence): Option[Array[Byte]]
- Definition Classes
- BaseEncoding
- final def tryDecode(data: Array[Char]): Option[Array[Byte]]
- Definition Classes
- BaseEncoding
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])