Encrypted Data Journal

Mixed C/NIM Code Example

Category: Software,
Tags: c download nim

  • Browse C wrapper source code (main.c and session.nim) which is part of ..
  • The NIM source code for the crypto library on GitHub.
  • Portal for the NIM Language
  • About a C backend for high-level language programming

Code Base Overview

      main.c
    +--------------------------------------------------+ 
    | main programme 'main.c', C code                  |     front end wrapper
    +--------------------------------------------------+

    +--------------------------------------------------+
    |                                                  |
    |   session.nim                                    |
    |  +--------------------------------------------+  |
    |  | glue code, C/NIM wrapper, NIM code         |  |
    |  +--------------------------------------------+  |
    |                                                  |
    |   crypto library                                 |
    |  +--------------------------------------------+  |
    |  |  +--------------------------------------+  |  |     source code for
    |  |  | session and key management, NIM code |  |  |     libsession.a
    |  |  +--------------------------------------+  |  |     library
    |  |                                            |  |
    |  |  +--------------------------------------+  |  |
    |  |  | basic crypto methods, C code         |  |  |
    |  |  +--------------------------------------+  |  |
    |  +--------------------------------------------+  |
    |                                                  |
    +--------------------------------------------------+

Compilation

There various compilation options described in the README file that comes with the sources. Here is the easy variant.

Install the NIM compiler from the portal and fetch the sources from the GitHub repositor via

   git clone https://github.com/mjfh/nim-crypto.git

Then run

   cd nim-crypto
   make -f Makefile.simple
   ./src/cwrap
   ./src/cwrap "how much wood could a woodchuck chuck"
   make distclean

Please read the sources. They are meant to provide a proof-of-concept but you are free to use them as a start for your own project.

back to top