Sha256: 860b735643f3d5e97c1304ec17b94c7d21e9129100699c44f14a907b368f77fa

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

#include <string>
using std::string;
#include <stdio.h>
#include "crypto_secretbox.h"
#include "randombytes.h"

main()
{
  int mlen;
  for (mlen = 0;mlen < 1000;++mlen) {
    unsigned char kbytes[crypto_secretbox_KEYBYTES];
    randombytes(kbytes,crypto_secretbox_KEYBYTES);
    string k((char *) kbytes,crypto_secretbox_KEYBYTES);
    unsigned char nbytes[crypto_secretbox_NONCEBYTES];
    randombytes(nbytes,crypto_secretbox_NONCEBYTES);
    string n((char *) nbytes,crypto_secretbox_NONCEBYTES);
    unsigned char mbytes[mlen];
    randombytes(mbytes,mlen);
    string m((char *) mbytes,mlen);
    string c = crypto_secretbox(m,n,k);
    try {
      string m2 = crypto_secretbox_open(c,n,k);
      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/secretbox5.cpp
ruby_nacl-0.1.1 ext/ruby_nacl/NaCl/tests/secretbox5.cpp
ruby_nacl-0.1.0 ext/ruby_nacl/NaCl/tests/secretbox5.cpp