Skip to content

Commit

Permalink
Created Conversions module to use for the new functions in haskell-cr…
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonlambda committed Oct 14, 2023
1 parent ccf0f23 commit 6626c15
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions libsodium-bindings/libsodium-bindings.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ library
LibSodium.Bindings
LibSodium.Bindings.AEAD
LibSodium.Bindings.Comparison
LibSodium.Bindings.Conversions
LibSodium.Bindings.CryptoAuth
LibSodium.Bindings.CryptoBox
LibSodium.Bindings.CryptoSign
Expand Down
38 changes: 38 additions & 0 deletions libsodium-bindings/src/LibSodium/Bindings/Conversions.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{-# LANGUAGE CApiFFI #-}

-- |
-- Module: LibSodium.Bindings.Conversions
-- Description: Sodium Conversions
-- Copyright: (C) Lemon
-- License: MIT
-- Maintainer: [email protected]
-- Stability: Stable
-- Portability: GHC only
module LibSodium.Bindings.Conversions
( -- * Functions
) where

import Foreign
import Foreign.C
import Foreign.C.ConstPtr

foreign import capi "sodium.h sodium_bin2base64"
sodiumBin2Base64
:: ConstPtr CChar
-- ^ Resulting conversion to base64 is stored here including C null terminator
-> CSize
-- ^ Maximum number of bytes allowed to be stored in base64 number when converting
-- ^ WARNING: Must be 2 * binLen + 1 in size
-- ^ NOTE: This is `const size_t` in sodium
-> ConstPtr CUChar
-- ^ Decimal numbers to convert to base64
-- ^ NOTE: This is `const unsigned char *const` in sodium
-> CSize
-- ^ Amount of bytes to convert to base64
-- ^ NOTE:
-- ^ NOTE: This is `const size_t` in sodium
-> CInt
-- ^ The variant of base64 to use
-- ^ NOTE: This is `const int` in sodium
-> Ptr CChar
-- ^ The result of converting bin to base64

0 comments on commit 6626c15

Please sign in to comment.