|
10 | 10 | #include "nbl/system/CColoredStdoutLoggerWin32.h"
|
11 | 11 | #include "nbl/system/IApplicationFramework.h"
|
12 | 12 |
|
| 13 | +#include "blake3.h" |
13 | 14 | #include <iostream>
|
14 | 15 | #include <cstdio>
|
| 16 | +#include <errno.h> |
| 17 | +#include <stdio.h> |
| 18 | +#include <stdlib.h> |
| 19 | +#include <string.h> |
15 | 20 |
|
16 | 21 | // if this config cmake flag is available then we embedded resources using cmake into C++ source
|
17 | 22 | #ifdef NBL_EMBED_BUILTIN_RESOURCES
|
@@ -252,6 +257,38 @@ int main(int argc, char** argv)
|
252 | 257 | wp.workingDirectory = CWD;
|
253 | 258 | assetManager->writeAsset("pngWriteSuccessful.png", wp);
|
254 | 259 | }
|
| 260 | + |
| 261 | +#ifdef NBL_ENABLE_BLAKE_TEST |
| 262 | + // blake3 hash. TODO: use with Nabla |
| 263 | + { |
| 264 | + // Initialize the hasher. |
| 265 | + blake3_hasher hasher; |
| 266 | + blake3_hasher_init(&hasher); |
| 267 | + |
| 268 | + std::array<unsigned char, 65536> buf; |
| 269 | + while (true) |
| 270 | + { |
| 271 | + std::cin.getline(reinterpret_cast<char*>(buf.data()), buf.size()); |
| 272 | + std::streamsize n = std::cin.gcount(); |
| 273 | + |
| 274 | + if (n < 2 || std::cin.eof()) |
| 275 | + break; |
| 276 | + else |
| 277 | + blake3_hasher_update(&hasher, buf.data(), n); |
| 278 | + } |
| 279 | + |
| 280 | + // Finalize the hash. BLAKE3_OUT_LEN is the default output length, 32 bytes. |
| 281 | + uint8_t output[BLAKE3_OUT_LEN]; |
| 282 | + blake3_hasher_finalize(&hasher, output, BLAKE3_OUT_LEN); |
| 283 | + |
| 284 | + // Print the hash as hexadecimal. |
| 285 | + for (size_t i = 0; i < BLAKE3_OUT_LEN; i++) { |
| 286 | + printf("%02x", output[i]); |
| 287 | + } |
| 288 | + printf("\n"); |
| 289 | + } |
| 290 | +#endif // NBL_ENABLE_BLAKE_TEST |
| 291 | + |
255 | 292 | //JPEG loader test
|
256 | 293 | if (auto cpuImage = checkedLoad.operator()<nbl::asset::ICPUImage>("dwarf.jpg"))
|
257 | 294 | {
|
|
0 commit comments