Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,43 @@
(setq *Alphabet
(chop "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"))
# if returns NIL then adress is already invalid
(de base58 (Str)
(let N 0
(for L (chop Str)
(setq N
(+
(* N 58)
(index L *Alphabet)
-1 ) ) )
N )
)
(de sha256 (Lst)
(native "libcrypto.so" "SHA256"
'(B . 32)
(cons
NIL
(32)
(native "libcrypto.so" "SHA256" '(B . 32)
(cons NIL (32) Lst) (length Lst) '(NIL (32))) )
32
'(NIL (32)) ) )
(de bytes25 (N)
(flip
(make
(do 25
(link (% N 256))
(setq N (/ N 256)) ) ) ) )
(de valid (Str)
(and
(base58 Str)
(bytes25 @)
(=
(head 4 (sha256 (head 21 @)))
(tail 4 @) ) ) )
(bye)