Thanks, but I seem to be producing incorrect results.

The expected result for a BLAKE2b-384 digest of "1234567890" 
is 
5a5f07b659b97436674e047c1f68d2513aea801e8722aeba5af5a3bf4fd20032b1e0182078389a1b76bae77f1d536950

and the program below is producing a digest 
of 
F54AEB1C4848FB988266C7E347C15F6CB4B2D896FC7A7127074C956508192ED8C7644AC492999532207986D10EF43652

std::string hash(std::string input)
{
   CryptoPP::byte const* pbData = (CryptoPP::byte*)input.data();
  unsigned int nDataLen = input.length();
CryptoPP::byte abDigest[48];

        CryptoPP::BLAKE2b(48).CalculateTruncatedDigest(abDigest, 48, pbData, 
nDataLen);

        return std::string((char*)abDigest, 48);
}

std::string to_hex(const std::string& input)
{
  CryptoPP::byte const* pbData = (CryptoPP::byte*)input.data();
  unsigned int nDataLen = input.length();

        std::string output;

        CryptoPP::HexEncoder hex(new CryptoPP::StringSink(output));
    hex.Put(pbData, nDataLen);
     hex.MessageEnd();

        return output;
}

int main(int argc, char* argv[])
{
      std::string text = "1234567890";

        std::cout << to_hex(hash(text)) std::endl;

        return 0;
}

Also changing the digest length for other lengths seems to produce just the 
first `x` bytes of a larger hash i.e. for the string "1234567890"

I.e. the following:

BLAKE2b_384:    
F54AEB1C4848FB988266C7E347C15F6CB4B2D896FC7A7127074C956508192ED8C7644AC492999532207986D10EF43652
BLAKE2b_320:    
F54AEB1C4848FB988266C7E347C15F6CB4B2D896FC7A7127074C956508192ED8C7644AC492999532
BLAKE2b_256:    
F54AEB1C4848FB988266C7E347C15F6CB4B2D896FC7A7127074C956508192ED8
BLAKE2b_224:    F54AEB1C4848FB988266C7E347C15F6CB4B2D896FC7A7127074C9565
BLAKE2b_192:    F54AEB1C4848FB988266C7E347C15F6CB4B2D896FC7A7127
BLAKE2b_128:    F54AEB1C4848FB988266C7E347C15F6C
BLAKE2b_64:      F54AEB1C4848FB98

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to