Base 58 Encoding: Difference between revisions

From Bitcoin Wiki
Jump to navigation Jump to search
Andy1001 (talk | contribs)
m Add: Category:Technical
Casascius (talk | contribs)
Moving to Base58Check encoding. (only 3 edits prior to mine, I don't have move privileges, so I'm copying and changing to redirect)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==Base 58 Encoding==
#REDIRECT [[Base58Check encoding]]
 
Base 58 encoding is used for encoding addresses.
 
Address = Base58Encode(RIPEMD160(SHA-256(public key))
 
The public key is expressed as an encoded point.
 
{| class="wikitable"
|-
!Code
!Character
!Code
!Character
!Code
|Character
!Code
!Character
|-
|0
|1
|1
|2
|2
|3
|3
|4
|-
|4
|5
|5
|6
|6
|7
|7
|8
|-
|8
|9
|9
|A
|10
|B
|11
|C
|-
|12
|D
|13
|E
|14
|F
|15
|G
|-
|16
|H
|17
|J
|18
|K
|19
|L
|-
|20
|M
|21
|N
|22
|P
|23
|Q
|-
|24
|R
|25
|S
|26
|T
|27
|U
|-
|28
|V
|29
|W
|30
|X
|31
|Y
|-
|32
|Z
|33
|a
|34
|b
|35
|c
|-
|36
|d
|37
|e
|38
|f
|39
|g
|-
|40
|h
|41
|i
|42
|j
|43
|k
|-
|44
|m
|45
|n
|46
|o
|47
|p
|-
|48
|q
|49
|r
|50
|s
|51
|t
|-
|52
|u
|53
|v
|54
|w
|55
|x
|-
|56
|y
|57
|z
|}
 
The algorithm for encoding is
 
    code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
    x = convert_bytes_to_big_integer(hash_result)
   
    output_string = ""
   
    while(x > 0)
        {
            (x, remainder) = divide(x, 58)
            output_string.append(output_string[remainder])
        }
   
    repeat(number_of_leading_zeros_in_hash)
        {
        output_string.append(output_string[0]);
        }
   
    output_string.reverse();
 
== Source ==
https://github.com/bitcoin/bitcoin/blob/master/src/base58.h
 
[[Category:Technical]]

Latest revision as of 03:16, 20 September 2011