@The Gecko :I'm guessing something is wrong but what? Given photo1 is 1.3MB
and photo2 32K

Don't know if you're still stuck but...

You are trying to output binary and that isn't pretty. Try something along
the lines of:
printf("%2.2x", bufferzz1[ i ] );

In a for loop where "i"  is incremented till the end of bufferzz1. Here is
some example program I just wrote (btw I am just learning c++ so I could be
wrong :)... If anyone notices anything off in my reply please correct me :])
to try out the library... It simply calculates a HASH and HMAC using
predefined data and outputs them to stdout.

Example:
--------
#include "/usr/local/include/cryptopp/modes.h"
#include "/usr/local/include/cryptopp/hex.h"
#include "/usr/local/include/cryptopp/filters.h"
#include "/usr/local/include/cryptopp/osrng.h"
#include "/usr/local/include/cryptopp/sha.h"
#include "/usr/local/include/cryptopp/hmac.h"

#include <iostream>

using namespace CryptoPP;
using namespace std;

int main( int argc, char** argv )
{
  const byte pbData[] =
  {
        0x32, 0x30, 0x30, 0x35, 0x31, 0x31, 0x30, 0x37,
        0x30, 0x34, 0x34, 0x30, 0x62, 0x6F, 0x62, 0x65,
        0x79
  };
  unsigned int nDataLen = 17;
  byte pbOutputBuffer[CryptoPP::SHA::BLOCKSIZE];
  byte pbOutputBuffer2[CryptoPP::SHA::BLOCKSIZE];
  memset( pbOutputBuffer, 0x00, CryptoPP::SHA::BLOCKSIZE );
  memset( pbOutputBuffer2, 0x00, CryptoPP::SHA::BLOCKSIZE );
  const byte pbKey[] =
  {
        0x90, 0x93, 0x1b, 0x2c, 0xb2, 0x20, 0x74, 0xa9, 0xa9, 0x21, 0x40,
0xc2, 0xf2, 0x5a, 0x31, 0x59, 0x2c, 0x91, 0xcd, 0x8d, 0xd6
, 0xa0, 0x66, 0xc4, 0x57, 0xfe, 0xef, 0xc6, 0x1f, 0xe8, 0x73, 0xdc, 0x25,
0x81, 0x6d, 0x70, 0x35, 0xc8, 0x7c, 0x05, 0x35, 0x50, 0xef
, 0x6e, 0x06, 0x1d, 0x54, 0x45, 0xb5, 0xda, 0x82, 0x7b, 0x43, 0x02, 0x43,
0xa4, 0x2c, 0xd2,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x1e, 0x1e, 0xa2, 0xee, 0x31, 0x31, 0xe1, 0x7e, 0x97, 0x84, 0xc2, 0x1e,
0x49, 0x69, 0xcc
  };
  unsigned int nKeyLen = 256;

  SHA().CalculateDigest(pbOutputBuffer, pbData, nDataLen);
  //HMAC<SHA >(pbKey, nKeyLen).CalculateDigest(pbOutputBuffer2, pbData,
nDataLen);
  HMAC<SHA > mac;
  mac.SetKey(pbKey, nKeyLen);
  mac.Update(pbOutputBuffer, nDataLen);
  mac.Final(pbOutputBuffer2);
  printf( "SHA: " );
  for( int i = 0; i < 20; i++ )
  {
        printf("%2.2x", pbOutputBuffer[ i ] );
        //cout <<  hex << (0xFF &pbOutputBuffer[ i ]);
  }
  cout << endl;
  printf( "HMAC: " );
  for( int i = 0; i < 20; i++ )
  {
        printf("%2.2x", pbOutputBuffer2[ i ] );
  }
  cout << endl;

  return 0;

}

// jpb

Reply via email to