Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created November 3, 2016 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/56c201550e4c82e398dcdc7ba6157ef1 to your computer and use it in GitHub Desktop.
Save zoffixznet/56c201550e4c82e398dcdc7ba6157ef1 to your computer and use it in GitHub Desktop.
use NativeCall;
constant DEMO = './target/debug/embed';
class CCRNG is repr('CPointer') { };
sub chacha_handle() returns CCRNG is native(DEMO) { * }
sub chacha_free(CCRNG) is native(DEMO) { * }
sub chacha_fill(CCRNG, CArray[uint8] is rw) is native(DEMO) { * }
my $buf = CArray[uint8].new;
$buf[7] = 0;
# say $buf;
my $ptr = chacha_handle();
chacha_fill($ptr, $buf);
say $buf[0..7];
chacha_free($ptr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment