1 // Copyright 2019 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "testing/utils/hash.h" 6 7 #include "core/fdrm/fx_crypt.h" 8 CryptToBase16(const uint8_t * digest)9std::string CryptToBase16(const uint8_t* digest) { 10 static char const zEncode[] = "0123456789abcdef"; 11 std::string ret; 12 ret.resize(32); 13 for (int i = 0, j = 0; i < 16; i++, j += 2) { 14 uint8_t a = digest[i]; 15 ret[j] = zEncode[(a >> 4) & 0xf]; 16 ret[j + 1] = zEncode[a & 0xf]; 17 } 18 return ret; 19 } 20 GenerateMD5Base16(const uint8_t * data,uint32_t size)21std::string GenerateMD5Base16(const uint8_t* data, uint32_t size) { 22 uint8_t digest[16]; 23 CRYPT_MD5Generate({data, size}, digest); 24 return CryptToBase16(digest); 25 } 26