mirror of
https://github.com/urbit/shrub.git
synced 2024-12-15 04:22:48 +03:00
Clean up base58 en/decoding
This commit is contained in:
parent
4352293d44
commit
004ac54d28
26
lib/bip.hoon
26
lib/bip.hoon
@ -220,27 +220,25 @@
|
|||||||
(cut 3 [vw (sub (met 3 x) (add 4 vw))] x)
|
(cut 3 [vw (sub (met 3 x) (add 4 vw))] x)
|
||||||
::
|
::
|
||||||
++ en-base58
|
++ en-base58
|
||||||
|= a=@
|
|= dat=@
|
||||||
=/ cha
|
=/ cha
|
||||||
'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||||
%- flop
|
%- flop
|
||||||
|- ^- tape
|
|- ^- tape
|
||||||
?: =(0 a) ~
|
?: =(0 dat) ~
|
||||||
:- (cut 3 [(mod a 58) 1] cha)
|
:- (cut 3 [(mod dat 58) 1] cha)
|
||||||
$(a (div a 58))
|
$(dat (div dat 58))
|
||||||
::
|
::
|
||||||
++ de-base58
|
++ de-base58
|
||||||
=- |=(t=tape (scan t fel))
|
|= t=tape
|
||||||
=< fel=(bass 58 .)
|
=- (scan t (bass 58 (plus -)))
|
||||||
=- (cook welp ;~(plug (plus siw) (stun 0^2 (cold %0 tis))))
|
|
||||||
^= siw
|
|
||||||
;~ pose
|
;~ pose
|
||||||
(cook |=(a/@ (sub a 56)) (shim 'A' 'H'))
|
(cook |=(a=@ (sub a 56)) (shim 'A' 'H'))
|
||||||
(cook |=(a/@ (sub a 57)) (shim 'J' 'N'))
|
(cook |=(a=@ (sub a 57)) (shim 'J' 'N'))
|
||||||
(cook |=(a/@ (sub a 58)) (shim 'P' 'Z'))
|
(cook |=(a=@ (sub a 58)) (shim 'P' 'Z'))
|
||||||
(cook |=(a/@ (sub a 64)) (shim 'a' 'k'))
|
(cook |=(a=@ (sub a 64)) (shim 'a' 'k'))
|
||||||
(cook |=(a/@ (sub a 65)) (shim 'm' 'z'))
|
(cook |=(a=@ (sub a 65)) (shim 'm' 'z'))
|
||||||
(cook |=(a/@ (sub a 49)) (shim '1' '9'))
|
(cook |=(a=@ (sub a 49)) (shim '1' '9'))
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
|
Loading…
Reference in New Issue
Block a user