sodium: add sodium-base64>bin
parent
05796cb497
commit
cefb0c6e9e
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2017 Alexander Ilin.
|
! Copyright (C) 2017 Alexander Ilin.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: byte-arrays init io.encodings.string io.encodings.utf8
|
USING: alien.c-types alien.data byte-arrays init io.encodings.ascii
|
||||||
kernel math sequences sodium.ffi ;
|
io.encodings.string io.encodings.utf8 kernel locals math sequences
|
||||||
|
sodium.ffi ;
|
||||||
IN: sodium
|
IN: sodium
|
||||||
|
|
||||||
ERROR: sodium-init-fail ;
|
ERROR: sodium-init-fail ;
|
||||||
|
@ -108,4 +109,10 @@ ERROR: sodium-malloc-error ;
|
||||||
dup length [ box-message-buf dup rot ] keep
|
dup length [ box-message-buf dup rot ] keep
|
||||||
] 3dip crypto_box_open_easy check0 ;
|
] 3dip crypto_box_open_easy check0 ;
|
||||||
|
|
||||||
|
:: sodium-base64>bin ( string -- byte-array )
|
||||||
|
string length dup <byte-array> dup :> bin swap
|
||||||
|
string ascii encode dup length f 0 size_t <ref> dup :> bin-length f
|
||||||
|
sodium_base64_VARIANT_URLSAFE_NO_PADDING sodium_base642bin check0
|
||||||
|
bin bin-length size_t deref head ;
|
||||||
|
|
||||||
[ sodium-init ] "sodium" add-startup-hook
|
[ sodium-init ] "sodium" add-startup-hook
|
||||||
|
|
Loading…
Reference in New Issue