CRC32

在与api交互中请求需提交文件的crc32 (循环冗余校验)

function Get-CRC32 {
    param(
        [Parameter(Mandatory = $False)]
        [Int]$InitialCRC = 0,
        [Parameter(Mandatory = $True)]
        [Byte[]]$Buffer
    )

    Add-Type -TypeDefinition @"
        using System;
        using System.Diagnostics;
        using System.Runtime.InteropServices;
        using System.Security.Principal;
    
        public static class CRC32
        {
            [DllImport("ntdll.dll")]
            public static extern UInt32 RtlComputeCrc32(
                UInt32 InitialCrc,
                Byte[] Buffer,
                Int32 Length);
        }
"@
    [CRC32]::RtlComputeCrc32($InitialCRC, $Buffer, $Buffer.Length)
}
原文地址:https://www.cnblogs.com/feiyucha/p/12640073.html