[{"data":1,"prerenderedAt":296},["ShallowReactive",2],{"blog:2007:calculating-crc-64-in-c-and-net":3,"blogMore-Development":282,"comments-calculating-crc-64-in-c-and-net":295},{"id":4,"title":5,"body":6,"category":263,"commentCount":264,"date":265,"description":266,"excerpt":267,"extension":268,"filenames":269,"hidden":270,"image":269,"meta":271,"minutes":85,"navigation":109,"path":272,"seo":273,"showCategory":269,"stem":274,"tags":275,"updated":269,"url":279,"wordCount":280,"__hash__":281},"content\u002Fblog\u002F2007\u002Fcalculating-crc-64-in-c-and-net.md","Calculating CRC-64 in C# and .NET",{"type":7,"value":8,"toc":261},"minimark",[9,26,32,43,46,242,251,257],[10,11,12,13,18,19,25],"p",{},"Seeing how the ",[14,15,17],"a",{"href":16},"\u002Fblog\u002F2006\u002Fcalculating_crc32_in_c_and_net\u002F","CRC-32 C# class I posted some time ago"," continues to get lots of Google hits I thought I’d post a ",[14,20,24],{"href":21,"rel":22},"https:\u002F\u002Fwww.cesnet.cz\u002Fdoc\u002Ftechzpravy\u002F2005\u002Fcrc64\u002F",[23],"nofollow","CRC-64"," version which will no doubt be far less popular being the more limited use. Again, do not use this as a secure message signature, it’s really for backward compatibility with legacy systems.",[27,28,29],"blockquote",{},[10,30,31],{},"This is the ISO-3309 version of CRC-64 algorithm. It is not compatible with the ECMA-182 algorithm.",[27,33,34],{},[10,35,36,37,42],{},"GitHub has the ",[14,38,41],{"href":39,"rel":40},"https:\u002F\u002Fgithub.com\u002Fdamieng\u002FDamienGKit\u002Fblob\u002Fmaster\u002FCSharp\u002FDamienG.Library\u002FSecurity\u002FCryptography\u002FCrc64.cs",[23],"latest version of Crc64",".",[10,44,45],{},"To use this or the CRC-32 class to compute the hash for a file simply:",[47,48,53],"pre",{"className":49,"code":50,"language":51,"meta":52,"style":52},"language-csharp shiki shiki-themes everforest-light dracula","Crc64 crc64 = new Crc64();\nString hash = String.Empty;\n\nusing (FileStream fs = File.Open(\"c:\\\\myfile.txt\", FileMode.Open))\n  foreach (byte b in crc64.ComputeHash(fs)) hash += b.ToString(\"x2\").ToLower();\n\nConsole.WriteLine(\"CRC-64 is {0}\", hash);\n","csharp","",[54,55,56,83,104,111,163,216,221],"code",{"__ignoreMap":52},[57,58,61,65,69,73,77,80],"span",{"class":59,"line":60},"line",1,[57,62,64],{"class":63},"snuxY","Crc64",[57,66,68],{"class":67},"s6Vpi"," crc64 ",[57,70,72],{"class":71},"s9HRq","=",[57,74,76],{"class":75},"smiwp"," new",[57,78,79],{"class":63}," Crc64",[57,81,82],{"class":67},"();\n",[57,84,86,89,92,94,97,101],{"class":59,"line":85},2,[57,87,88],{"class":63},"String",[57,90,91],{"class":67}," hash ",[57,93,72],{"class":71},[57,95,96],{"class":67}," String.",[57,98,100],{"class":99},"sSKRk","Empty",[57,102,103],{"class":67},";\n",[57,105,107],{"class":59,"line":106},3,[57,108,110],{"emptyLinePlaceholder":109},true,"\n",[57,112,114,117,120,123,126,128,131,135,138,142,146,150,153,155,158,160],{"class":59,"line":113},4,[57,115,116],{"class":75},"using",[57,118,119],{"class":67}," (",[57,121,122],{"class":63},"FileStream",[57,124,125],{"class":67}," fs ",[57,127,72],{"class":71},[57,129,130],{"class":67}," File.",[57,132,134],{"class":133},"sS4Kt","Open",[57,136,137],{"class":67},"(",[57,139,141],{"class":140},"sciFF","\"",[57,143,145],{"class":144},"sJQOs","c:",[57,147,149],{"class":148},"smfUS","\\\\",[57,151,152],{"class":144},"myfile.txt",[57,154,141],{"class":140},[57,156,157],{"class":67},", FileMode.",[57,159,134],{"class":99},[57,161,162],{"class":67},"))\n",[57,164,166,169,171,175,178,181,184,187,190,193,196,199,201,203,206,208,211,214],{"class":59,"line":165},5,[57,167,168],{"class":75},"  foreach",[57,170,119],{"class":67},[57,172,174],{"class":173},"sXAHl","byte",[57,176,177],{"class":67}," b ",[57,179,180],{"class":75},"in",[57,182,183],{"class":67}," crc64.",[57,185,186],{"class":133},"ComputeHash",[57,188,189],{"class":67},"(fs)) hash ",[57,191,192],{"class":71},"+=",[57,194,195],{"class":67}," b.",[57,197,198],{"class":133},"ToString",[57,200,137],{"class":67},[57,202,141],{"class":140},[57,204,205],{"class":144},"x2",[57,207,141],{"class":140},[57,209,210],{"class":67},").",[57,212,213],{"class":133},"ToLower",[57,215,82],{"class":67},[57,217,219],{"class":59,"line":218},6,[57,220,110],{"emptyLinePlaceholder":109},[57,222,224,227,230,232,234,237,239],{"class":59,"line":223},7,[57,225,226],{"class":67},"Console.",[57,228,229],{"class":133},"WriteLine",[57,231,137],{"class":67},[57,233,141],{"class":140},[57,235,236],{"class":144},"CRC-64 is {0}",[57,238,141],{"class":140},[57,240,241],{"class":67},", hash);\n",[10,243,244,245,250],{},"While writing this I considered if I should implement some more advanced hashing algorithms missing from .NET like RIPEMD320 only to stumble across ",[14,246,249],{"href":247,"rel":248},"https:\u002F\u002Fwww.bouncycastle.org\u002Fcsharp\u002Findex.html",[23],"The Legion of Bouncy Castles C# Cryptography APIs"," which also includes generating PKCS #12 files and a whole bunch of encryption algorithms (but nothing as weak as CRC-64 ;-)",[10,252,253],{},[254,255,256],"em",{},"[)amien",[258,259,260],"style",{},"html pre.shiki code .snuxY, html code.shiki .snuxY{--shiki-default:#3A94C5;--shiki-default-font-style:inherit;--shiki-dark:#8BE9FD;--shiki-dark-font-style:italic}html pre.shiki code .s6Vpi, html code.shiki .s6Vpi{--shiki-default:#5C6A72;--shiki-dark:#F8F8F2}html pre.shiki code .s9HRq, html code.shiki .s9HRq{--shiki-default:#F57D26;--shiki-dark:#FF79C6}html pre.shiki code .smiwp, html code.shiki .smiwp{--shiki-default:#F85552;--shiki-dark:#FF79C6}html pre.shiki code .sSKRk, html code.shiki .sSKRk{--shiki-default:#35A77C;--shiki-dark:#F8F8F2}html pre.shiki code .sS4Kt, html code.shiki .sS4Kt{--shiki-default:#8DA101;--shiki-dark:#50FA7B}html pre.shiki code .sciFF, html code.shiki .sciFF{--shiki-default:#8DA101;--shiki-dark:#E9F284}html pre.shiki code .sJQOs, html code.shiki .sJQOs{--shiki-default:#8DA101;--shiki-dark:#F1FA8C}html pre.shiki code .smfUS, html code.shiki .smfUS{--shiki-default:#DFA000;--shiki-dark:#FF79C6}html pre.shiki code .sXAHl, html code.shiki .sXAHl{--shiki-default:#3A94C5;--shiki-dark:#FF79C6}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":85,"depth":85,"links":262},[],"Development",0,"2007-11-19T12:53:32+00:00","Seeing how the CRC-32 C# class I posted some time ago continues to get lots of Google hits I thought I’d post a CRC-64 version which will no doubt be far less popular being the more limited use. Again, do not use this as a secure message signature, it’s really for backward compatibility with legacy systems.","[object Object]","md",null,false,{},"\u002Fblog\u002F2007\u002Fcalculating-crc-64-in-c-and-net",{"title":5,"description":266},"blog\u002F2007\u002Fcalculating-crc-64-in-c-and-net",[276,277,278],".NET","C#","hashing","\u002Fblog\u002F2007\u002Fcalculating-crc-64-in-c-and-net\u002F",301,"4FGP_TRsE0L7BmT_bPECJgQNxqcd-ifi1Q-1cp93OLg",[283,287,291],{"title":284,"date":285,"url":286},"Transactions in the MongoDB EF Core Provider","2025-10-25","\u002Fblog\u002F2025\u002Fmongodb-explicit-transactions\u002F",{"title":288,"date":289,"url":290},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","\u002Fblog\u002F2025\u002Fmongodb-queryable-encryption\u002F",{"title":292,"date":293,"url":294},"Lazy Loading with EF Core Proxies","2025-04-02","\u002Fblog\u002F2025\u002Fef-proxies\u002F",[],1780900529637]