Sha256: 94133c6a0039ecaaaa1daaa97ed12fe554685a84a9047f81bcdae9be87453a0d

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/json/

#include "test.hpp"

#include <tao/json/internal/sha256.hpp>

namespace tao::json
{
   static char hex[] = "0123456789ABCDEF";

   [[nodiscard]] std::string to_hex( const std::string& s )
   {
      std::string result;
      result.reserve( s.size() * 2 );
      for( unsigned char c : s ) {
         result += hex[ c >> 4 ];
         result += hex[ c & 15 ];
      }
      return result;
   }

   void unit_test()
   {
      // two test vectors from RFC 6234 should be enough

      internal::sha256 d;
      d.feed( "abc" );
      TEST_ASSERT( to_hex( d.get() ) == "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD" );

      d.reset();
      d.feed( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" );
      TEST_ASSERT( to_hex( d.get() ) == "248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1" );
   }

}  // namespace tao::json

#include "main.hpp"

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.4 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.3 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.2 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.1-x86_64-linux ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.1-x86_64-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.1-universal-darwin-19 ext/third_party/json/src/test/json/sha256.cpp
couchbase-3.0.0.alpha.1 ext/third_party/json/src/test/json/sha256.cpp