Sha256: 995603c39c2a05734cdf1a429c27b127a206496ebd31e4cdf8e5d529b758259d
Contents?: true
Size: 782 Bytes
Versions: 3
Compression:
Stored size: 782 Bytes
Contents
#include <string> using std::string; #include <stdio.h> #include "crypto_box.h" #include "randombytes.h" main() { int mlen; for (mlen = 0;mlen < 1000;++mlen) { string alicesk; string alicepk = crypto_box_keypair(&alicesk); string bobsk; string bobpk = crypto_box_keypair(&bobsk); unsigned char nbytes[crypto_box_NONCEBYTES]; randombytes(nbytes,crypto_box_NONCEBYTES); string n((char *) nbytes,crypto_box_NONCEBYTES); unsigned char mbytes[mlen]; randombytes(mbytes,mlen); string m((char *) mbytes,mlen); string c = crypto_box(m,n,bobpk,alicesk); try { string m2 = crypto_box_open(c,n,alicepk,bobsk); if (m != m2) printf("bad decryption\n"); } catch(const char *s) { printf("%s\n",s); } } return 0; }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby_nacl-0.1.2 | ext/ruby_nacl/NaCl/tests/box5.cpp |
ruby_nacl-0.1.1 | ext/ruby_nacl/NaCl/tests/box5.cpp |
ruby_nacl-0.1.0 | ext/ruby_nacl/NaCl/tests/box5.cpp |