Example #1
0
File: c_aes.c Project: aikko/crypto
// Test AES
int main(void)
{
  byte key[] = {0x12,0x34,0x56,0x12,0x34,0x56,0x12,0x34,0x56,0x12,0x34,0x56,0x12,0x34,0x56,0x12};
  byte msg[] = {0xab,0xcd,0xef,0xab,0xcd,0xef,0xab,0xcd,0xef,0xab,0xcd,0xef,0xab,0xcd,0xef,0xab};
  byte encrypted[16], decrypted[16];

  printf("Test AES\r\n\n");
  Pretty(key,16,"Key:         ");
  Pretty(msg,16,"Original:    ");

  EncryptAES(msg,key,encrypted);
  printf("Encrypted should be: 85E5A3D7356A61E29A8AFA559AD67102\r\n");
  Pretty(encrypted,16,"Encrypted:   ");

  DecryptAES(encrypted,key,decrypted);
  Pretty(decrypted,16,"Decrypted:   ");
  
  return 0;
}
Example #2
0
// Display the BST horizontally --- based on a level-order traversal
void BST::Pretty(ostream &Out)
{
   int Skip = 0;

   if ( Root == NULL )  // Nothing to display!
   {  cout << "Empty tree!\n"; return;  }

   SetPos (Root, Skip); // Find line position for each node
   Pretty (Root, Out);  // Level-order traversal displaying the nodes
}                       // one line for each level, in proper position
Example #3
0
File: Pretty.cpp Project: maTHmU/nV
var Pretty(Kernel& k, const Rational& x) {
    mpq_canonicalize(const_cast<mpq_ptr>(x.mpq));
    Integer *a = new Integer, *b = new Integer;
    mpq_get_num(a->mpz, x.mpq);
    mpq_get_den(b->mpz, x.mpq);
    if(mpz_cmp_ui(b->mpz, 1) == 0)
        return Pretty(k, Z(a));
    if(mpz_sgn(a->mpz) < 0)
    {
        mpz_neg(a->mpz, a->mpz);
        return nV::tuple($.Minus, nV::tuple(SYS(Divide), a, b));
    }
Example #4
0
File: print.cpp Project: hyln9/nV
void Write(wostream &f, Var x)
{
	if(StrQ(x))
	{
		const wchar *s = CStr(x).c_str();
		size_t n = wcslen(s);
		for(size_t i = 0; i < n; ++i)
			FullPrint(s[i],f);
		f << std::endl;
	}
	else if(VecQ(x))
	{
		size_t n = Size(x);
		for(size_t i = 0; i < n; ++i)
			Print(Pretty(At(x,i)),f);
		f << std::endl;
	}
	else
		Println(x,f);
}