Casper.Network.SDK
Show / Hide Table of Contents

Class CEP57Checksum

CEP 0057 introduces a checksum for hex-encoded values based on the capitalization of letters in an hexadecimal string.

Inheritance
object
CEP57Checksum
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Casper.Network.SDK.Utils
Assembly: Casper.Network.SDK.dll
Syntax
public class CEP57Checksum

Fields

| Edit this page View Source

InvalidChecksum

Declaration
public const int InvalidChecksum = 2
Field Value
Type Description
int
| Edit this page View Source

NoChecksum

Declaration
public const int NoChecksum = 0
Field Value
Type Description
int
| Edit this page View Source

ValidChecksum

Declaration
public const int ValidChecksum = 1
Field Value
Type Description
int

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
Type Description
byte[]
| 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
Type Description
string
| 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
Type Description
bool
Exceptions
Type Condition
ArgumentException

This method trhows an exception if the string is not hexadecimal.

See Also

CEP 0057 Checksummed Addresses
  • Edit this page
  • View Source
In this article
Back to top Maintained by MAKE Technology LLC