PowerShell module with various commands to encode/encrypt/print byte arrays.
Cryptographic commands are using implementations from the BouncyCastle library. Consider donating them if you like this module.
Counts Hamming distance between bytes in arrays.
Nicely prints a byte array. Example:
> Get-Content -Encoding Byte C:\Windows\notepad.exe -TotalCount 96 | Format-HexPrettyPrint
0 1 2 3 4 5 6 7 8 9 A B C D E F
0000: 4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00 MZ..............
0010: b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ........@.......
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0030: 00 00 00 00 00 00 00 00 00 00 00 00 f0 00 00 00 ................
0040: 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 ........!..L.!Th
0050: 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f is program canno
Generates a byte array of randomly (cryptographically secure) generated bytes. Example:
PS> Get-RandomBytes -Length 10
25
192
252
150
203
166
195
174
190
222
Converts the byte array to the base64 encoded string. Example:
PS> Get-RandomBytes -Length 10 | ConvertTo-Base64String
LmIN1S5BGcu7RA==
Converts the base64 encoded string to the byte array.
Converts a byte array to its HEX representation. Example:
PS> Get-RandomBytes -Length 10 | ConvertTo-HexString
2d12ba68d2aaa3da9738
Converts a HEX string to a byte array.
Converts string to a byte array using a specified encoding.
Converts a byte array to a string using a specified encoding.
Encrypts the provided message using a symmetric cipher.
Decrypts the provided cipher text using a symmetric cipher.
Calculates a message digests and outputs it as a byte array. Example:
PS> $b = ConvertTo-ByteArray "test message"
PS> Get-MessageDigest -Digest SHA256 $b | ConvertTo-HexString
3f0a377ba0a4a460ecb616f6507ce0d8cfa3e704025d4fda3ed0c5ca05468728
Calculates a message MAC and outputs it as a byte array.
PS> $key = ConvertTo-ByteArray "YELLOW SUBMARINE"
PS> $b = ConvertTo-ByteArray "test message"
PS> Get-Mac -Key $key -BinaryMessage $b | ConvertTo-HexString
cfd4afbd065cacae3b33a848a9ce716e2d43eb06