Hi Anyone,

Still trying to get a blowfish function working.  Blowfish block size is 8, so what do i do for the last 8 bytes of an input string that is < 8.  Is it padded etc, or is there an easier way to do the loop iteration with other parts of CryptoPP ?

Thanks,

Dan

------------------------------------
 

std::string EncryptString(  const char * pszString,
                                      const char *passPhrase)
{
 std::string strOut;

  HexEncoder source(new StringSource((const byte*)pszString, strlen(pszString), true));
  HexEncoder output(new StringSink(strOut));

  ECB_Mode<Blowfish>::Encryption encryptor((byte *)passPhrase, strlen(passPhrase));
  ECB_Mode<Blowfish>::Decryption decryptor((byte *)passPhrase, strlen(passPhrase));

   unsigned int tuples = 0xffff;
  SecByteBlock plain(Blowfish::BLOCKSIZE), out(Blowfish::BLOCKSIZE),
            outtest(Blowfish::BLOCKSIZE);
  while (source.MaxRetrievable() && tuples--)
  {
   source.Get(plain, Blowfish::BLOCKSIZE);
   encryptor.ProcessData(out, plain, Blowfish::BLOCKSIZE);
   output.Put(out, Blowfish::BLOCKSIZE);
  } 
 }
 return strOut;
}

Reply via email to