Compression, ZIP and Hashing
Choose the right Sharp Runtime I/O component for compression, archives or checksums.
Separate concerns
| Job | Component | Dependency |
|---|---|---|
| Streaming compression | IO.Compression | ZLIB |
| ZIP archives | IO.Compression.Zip | Vendored miniz |
| Checksums/non-crypto hashes | IO.Hashing | No external library |
Select only the jobs you use
set(SHARP_RUNTIME_COMPONENTS
IO.Compression
IO.Hashing
)
target_link_libraries(app PRIVATE
SharpRuntime::IO.Compression
SharpRuntime::IO.Hashing
)
Compute a CRC-32 checksum
#include <iostream>
#include <string>
#include "System/IO/Hashing/Crc32.hpp"
using System::IO::Hashing::Crc32;
int main()
{
const std::string payload = "123456789";
const auto crc = Crc32::HashToUInt32(
reinterpret_cast<const SharpRuntime::bytecs*>(payload.data()),
static_cast<SharpRuntime::intcs>(payload.size()));
std::cout << std::hex << crc << '\n';
return crc == 0xCBF43926u ? 0 : 1;
}Built and run
The standard check vector produces cbf43926 at the pinned source. The pointer remains valid for the call and the length conversion is explicit.
Rules
- Finish/flush compression streams before consuming final output.
- Treat archive entry names as untrusted paths; enforce an extraction root.
- Do not use Adler32/CRC-style hashes for authentication or password storage.
- Use Security.Cryptography for the implemented crypto hashes/HMAC/PBKDF2 surface, and document its boundaries.