sodium: add sodium-base64>bin

master
Alexander Iljin 2020-04-27 18:20:22 +02:00 committed by Doug Coleman
parent 05796cb497
commit cefb0c6e9e
1 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,8 @@
! Copyright (C) 2017 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
USING: byte-arrays init io.encodings.string io.encodings.utf8
kernel math sequences sodium.ffi ;
USING: alien.c-types alien.data byte-arrays init io.encodings.ascii
io.encodings.string io.encodings.utf8 kernel locals math sequences
sodium.ffi ;
IN: sodium
ERROR: sodium-init-fail ;
@ -108,4 +109,10 @@ ERROR: sodium-malloc-error ;
dup length [ box-message-buf dup rot ] keep
] 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