[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / crypto / sha2.cc
1 // Copyright 2012 The Chromium 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 "crypto/sha2.h"
6
7 #include <stddef.h>
8
9 #include <memory>
10
11 #include "crypto/secure_hash.h"
12 #include "third_party/boringssl/src/include/openssl/sha.h"
13
14 namespace crypto {
15
16 std::array<uint8_t, kSHA256Length> SHA256Hash(base::span<const uint8_t> input) {
17   std::array<uint8_t, kSHA256Length> digest;
18   ::SHA256(input.data(), input.size(), digest.data());
19   return digest;
20 }
21
22 void SHA256HashString(std::string_view str, void* output, size_t len) {
23   std::unique_ptr<SecureHash> ctx(SecureHash::Create(SecureHash::SHA256));
24   ctx->Update(str.data(), str.length());
25   ctx->Finish(output, len);
26 }
27
28 std::string SHA256HashString(std::string_view str) {
29   std::string output(kSHA256Length, 0);
30   SHA256HashString(str, std::data(output), output.size());
31   return output;
32 }
33
34 }  // namespace crypto