tools
読み取り中…
検索中…
一致する文字列を見つけられません
crc32.h
[詳解]
1#pragma once
2#include <boost/crc.hpp>
3#include <iomanip>
4
5/**
6 * @file crc32.h
7 * @brief CRC32 チェックサム計算ユーティリティ
8 *
9 * Boost.CRC を使用して文字列の CRC32 チェックサムを計算します。
10 */
11
12/**
13 * @brief 文字列の CRC32 チェックサムを計算する
14 * @param data チェックサムを計算する対象の文字列
15 * @return 8桁ゼロ埋め16進数形式の CRC32 チェックサム文字列(例: "1a2b3c4d")
16 */
17std::string calculateCRC32(std::string data) {
18 boost::crc_32_type crc;
19 crc.process_bytes(data.data(), data.size());
20
21 std::ostringstream oss;
22 oss << std::hex << std::setw(8) << std::setfill('0') << crc.checksum(); // 8桁の16進数としてゼロ埋め
23
24 return oss.str();
25}
std::string calculateCRC32(std::string data)
文字列の CRC32 チェックサムを計算する
Definition crc32.h:17