Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
hash.cpp
Go to the documentation of this file.
1// Copyright 2019 The PDFium Authors
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
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
21std::string GenerateMD5Base16(pdfium::span<const uint8_t> data) {
22 uint8_t digest[16];
23 CRYPT_MD5Generate(data, digest);
24 return CryptToBase16(digest);
25}
std::string GenerateMD5Base16(pdfium::span< const uint8_t > data)
Definition hash.cpp:21
std::string CryptToBase16(const uint8_t *digest)
Definition hash.cpp:9