Class CEP57Checksum
CEP 0057 introduces a checksum for hex-encoded values based on the capitalization
of letters in an hexadecimal string.
Inheritance
CEP57Checksum
Assembly: Casper.Network.SDK.dll
Syntax
public class CEP57Checksum
Fields
|
Edit this page
View Source
InvalidChecksum
Declaration
public const int InvalidChecksum = 2
Field Value
|
Edit this page
View Source
NoChecksum
Declaration
public const int NoChecksum = 0
Field Value
|
Edit this page
View Source
ValidChecksum
Declaration
public const int ValidChecksum = 1
Field Value
Methods
|
Edit this page
View Source
Decode(string, out int)
Converts an hexadecimal string to an array of bytes.
If the string contains a valid checksum, checksumResult returns CEP57Checksum.ValidChecksum.
If the string contains an invalid checksum, checksumResultreturns CEP57Checksum.InvalidChecksum.
checkumResultreturns CEP57Checksum.NoChecksum if the string does not include CEP57 checksum.
Declaration
public static byte[] Decode(string hex, out int checksumResult)
Parameters
| Type |
Name |
Description |
| string |
hex |
|
| int |
checksumResult |
|
Returns
|
Edit this page
View Source
Encode(byte[])
Encodes an array of bytes into an hexadecimal string with CEP57 checksum.
Arrays longer than 75 bytes do not include the checksum.
Declaration
public static string Encode(byte[] input)
Parameters
| Type |
Name |
Description |
| byte[] |
input |
|
Returns
|
Edit this page
View Source
HasChecksum(string)
Returns true if the input hexadecimal string includes the CEP57 checksum.
An string includes checksum when letters are mixed-cased.
Declaration
public static bool HasChecksum(string hex)
Parameters
| Type |
Name |
Description |
| string |
hex |
|
Returns
Exceptions
| Type |
Condition |
| ArgumentException |
This method trhows an exception if the string is not hexadecimal.
|
See Also