CryptBinaryConverterAnyToBinary Method

Converts input string to a byte array. See Remarks for more details.

Definition

Namespace: SysadminsLV.PKI
Assembly: SysadminsLV.PKI (in SysadminsLV.PKI.dll) Version: 4.0.1
C#
public static byte[] AnyToBinary(
	string anyString
)

Parameters

anyString  String
A string encoded in Base64, hex or binary text.

Return Value

Byte
Decoded bytes

Remarks

This method is used to decode cryptographic messages formatted in various ways, such Base64 with or without headers, hex string, with or without address and ASCII panels or pure binary text.

This method attempts to decode string in the following order:

  • CRYPT_STRING_HEXADDR
  • CRYPT_STRING_HEXASCIIADDR
  • CRYPT_STRING_HEX
  • CRYPT_STRING_HEXRAW
  • CRYPT_STRING_HEXASCII
  • CRYPT_STRING_BASE64HEADER
  • CRYPT_STRING_BASE64
  • CRYPT_STRING_BINARY

Exceptions

Win32ExceptionIf the input string cannot be recognized and/or decoded.
ArgumentNullExceptionInput string is null or empty.

See Also