{"id":104,"date":"2026-01-22T15:11:13","date_gmt":"2026-01-22T15:11:13","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/d_eanes\/?p=104"},"modified":"2026-01-22T15:11:13","modified_gmt":"2026-01-22T15:11:13","slug":"blog-post-1-21-26","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/d_eanes\/2026\/01\/22\/blog-post-1-21-26\/","title":{"rendered":"Blog Post: 1\/21\/26"},"content":{"rendered":"\n<p>Today, I asked an AI to help me make code that can calculate the size and cryptographic checksums of binary files put in the directory. It does this by opening each file in small chunks, and it processes the data to generate CRC32, MD5, and SHA\u2011256 hashes, and then it prints all the results in a clean format. It uses th sys module to get the file names, os to check the file size, it uses binascii to create the CRC32 value, and hashlib to make the MD5 and SHA\u2011256 hashes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import sys\nimport os\nimport binascii\nimport hashlib\n\ndef crc32_hex(path):\n    crc = 0\n    with open(path, \"rb\") as f:\n        for chunk in iter(lambda: f.read(8192), b\"\"):\n            crc = binascii.crc32(chunk, crc)\n    # Ensure unsigned 32-bit and format as 8 lowercase hex digits\n    return format(crc &amp; 0xFFFFFFFF, \"08x\")\n\ndef md5_hex(path):\n    h = hashlib.md5()\n    with open(path, \"rb\") as f:\n        for chunk in iter(lambda: f.read(8192), b\"\"):\n            h.update(chunk)\n    return h.hexdigest()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today, I asked an AI to help me make code that can calculate the size and cryptographic checksums of binary files put in the directory. It does this by opening each file in small chunks, and it processes the data to generate CRC32, MD5, and SHA\u2011256 hashes, and then it prints all the results in&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":2,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts\/104\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}