Like [base64], but without these characters: `+/0OIl` This is the definition of base58 as used by the open source decentralized cryptographic peer-to-peer currency system bitcoin. (there is apparently a different version of base58 used by Flickr) The rationale (at least for bitcoin) behind the use of base58 is: * 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. The alphabet used is: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" ---- [JMN] 2011-06-28 Does anyone know if there are existing Tcl implementations of base58 as used by bitcoin? ---- '''[AK] - 2011-06-28 17:41:27''' I do not know of any implementation. If one is made by whoever I would strongly recommend to submit the code to Tcllib for inclusion, as it already has base64, base32, ascii85, uu, yEnc, etc. I.e. a base58 implementation would fit right in. ---- [aspect]: this came up in the [Tcl Chatroom] so I did a quick implementation. base58 is not so good for encoding binary chunks, as it doesn't correspond neatly to a length in bits. This version base58-encodes an integer: ====== proc base32 {int {alphabet 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz}} { set result {} set alen [string length $alphabet] while {$int} { set result $result[string index $alphabet [expr {$int%$alen}]] set int [expr {$int/$alen}] } set result } ====== An example usage to generate unique identifiers a la youtube might be: ====== package require md5 string range [base58 [md5::md5 -hex "myidentifier"]] 0 11 ====== Whether your identifiers are sufficiently unique is a matter for you to decide .. Note that the only rationale for including [md5] is to make the distribution more uniform and obscure the source of identifiers. The md5 output is also being truncated to a number between 0 and 58**12, or: ====== tclsh8.5 [~]list [expr log(58**12)/log(2)] bits 70.29577194153087 bits ====== <> Cryptography | Internet | Currency and Finance