Created
November 3, 2016 19:09
-
-
Save zoffixznet/56c201550e4c82e398dcdc7ba6157ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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