CRC-8 and Base32 in Powershell

Recently I was looking for functions that could be used in Powershell to calculate CRC-8 checksums and encoding to Base32. Finally I havent found any code that I could use, even trying to import system DLL functions from standard Windows libraries.

My code is published on github here: https://github.com/defragmentator/PowershellTools

  • CRC-8
    1. This implementation is exactly as CRC8-maxim/dallas
    2. Other types of CRC-8: probably it would be easy to implement other types of CRC8 by changing 0X8C in code
$c = (0x8C -bxor ($c -shr 1))

to some other values from Wiki with value of Polynomial representations named there in chart as “Reversed”. It was not testet yet!

  • Base32 is based on regexp so it is very unoptimal, but it works.

Example usage:

$b= [System.Text.Encoding]::ASCII.GetBytes("Power") | Get-Base32

"base32: $b"

$a= [System.Text.Encoding]::ASCII.GetBytes("Power") | Get-CRC8

[String]::Format("{0:x2}", $a)
$a.ToString("X2")