C# Class Utilities.Binary.Extensions.ByteExtensions

Mostra file Open project: feanz/Utilities

Public Methods

Method Description
Append ( this data, byte toAppend ) : byte[]

Appends the specified data to the source byte array

Base64ToByteArray ( this Input ) : byte[]

Converts base 64 string to a byte array

BinaryToByteArray ( this binary ) : byte[]

Convert binary string representation to byte array

BinaryToDecimal ( this text ) : string

Returns the decimal representation of a binary number.

BinaryToHex ( this text ) : string

Returns the hexadecimal representation of a binary number.

Compress ( this data, CompressionType compressionType = CompressionType.Deflate ) : byte[]

Compresses the data using the specified compression type

Compress ( this data, Encoding encodingUsing = null, CompressionType compressionType = CompressionType.Deflate ) : string

Compresses a string of data

DecimalToBinary ( this txt ) : string

Returns the binary representation of a binary number.

DecimalToHex ( this txt ) : string

Returns the hexadecimal representation of a decimal number.

Decompress ( this data, CompressionType CompressionType = CompressionType.Deflate ) : byte[]

Decompresses the byte array that is sent in

Decompress ( this data, Encoding EncodingUsing = null, CompressionType CompressionType = CompressionType.Deflate ) : string

Decompresses a string of data

HexToBinary ( this hex ) : string

Returns the binary representation of a hexadecimal number.

HexToByteArray ( this hex ) : byte[]

Converts a hexadecimal string to a byte array representation.

The string is assumed to be of even size.

HexToDecimal ( this hex ) : string

Returns the decimal representation of a hexadecimal number.

IsBinary ( this binary ) : bool

Validate if string is a valide binary representation

IsHex ( this hex ) : bool

Validate is string is a valide hex representation

IsUnicode ( this data ) : bool

Determines if a byte array is unicode

ToBase64String ( this data ) : string

Converts a byte array into a base 64 string

ToBinary ( this data ) : string

Convert byte array to a binary representation as a string

ToByteArray ( this input, Encoding encodingUsing = null ) : byte[]

Converts a string to a byte array

ToEncodedString ( this data, Encoding encodingUsing = null, int index, int count = -1 ) : string

Converts a byte array to a string

ToHex ( this data ) : string

Converts a byte array to a hexadecimal string representation.

ToHexNibble ( this data ) : byte

Convert byte to nibble (4 bit value)

ToInt32 ( this data ) : int

Convert byte array to a 32 bit int

ToNibbleString ( this data ) : string

Convert a byte array into a string with each byte represented as nibbles

Private Methods

Method Description
GetStream ( MemoryStream Stream, CompressionMode Mode, CompressionType CompressionType ) : Stream

Method Details

Append() public static method

Appends the specified data to the source byte array
public static Append ( this data, byte toAppend ) : byte[]
data this Byte array to be appended
toAppend byte Byte array to append.
return byte[]

Base64ToByteArray() public static method

Converts base 64 string to a byte array
public static Base64ToByteArray ( this Input ) : byte[]
Input this Input string
return byte[]

BinaryToByteArray() public static method

Convert binary string representation to byte array
public static BinaryToByteArray ( this binary ) : byte[]
binary this Binary string
return byte[]

BinaryToDecimal() public static method

Returns the decimal representation of a binary number.
public static BinaryToDecimal ( this text ) : string
text this Binary string to convert to decimal.
return string

BinaryToHex() public static method

Returns the hexadecimal representation of a binary number.
public static BinaryToHex ( this text ) : string
text this Binary string to convert to hexadecimal.
return string

Compress() public static method

Compresses the data using the specified compression type
public static Compress ( this data, CompressionType compressionType = CompressionType.Deflate ) : byte[]
data this data to compress
compressionType CompressionType Compression type
return byte[]

Compress() public static method

Compresses a string of data
public static Compress ( this data, Encoding encodingUsing = null, CompressionType compressionType = CompressionType.Deflate ) : string
data this data to Compress
encodingUsing System.Text.Encoding Encoding that the data uses (defaults to UTF8)
compressionType CompressionType The compression type used
return string

DecimalToBinary() public static method

Returns the binary representation of a binary number.
public static DecimalToBinary ( this txt ) : string
txt this Decimal string to convert to binary.
return string

DecimalToHex() public static method

Returns the hexadecimal representation of a decimal number.
public static DecimalToHex ( this txt ) : string
txt this Hexadecimal string to convert to decimal.
return string

Decompress() public static method

Decompresses the byte array that is sent in
public static Decompress ( this data, CompressionType CompressionType = CompressionType.Deflate ) : byte[]
data this data to decompress
CompressionType CompressionType The compression type used
return byte[]

Decompress() public static method

Decompresses a string of data
public static Decompress ( this data, Encoding EncodingUsing = null, CompressionType CompressionType = CompressionType.Deflate ) : string
data this data to decompress
EncodingUsing System.Text.Encoding Encoding that the result should use (defaults to UTF8)
CompressionType CompressionType The compression type used
return string

HexToBinary() public static method

Returns the binary representation of a hexadecimal number.
public static HexToBinary ( this hex ) : string
hex this Binary string to convert to hexadecimal.
return string

HexToByteArray() public static method

Converts a hexadecimal string to a byte array representation.
The string is assumed to be of even size.
public static HexToByteArray ( this hex ) : byte[]
hex this Hexadecimal string to convert to byte array.
return byte[]

HexToDecimal() public static method

Returns the decimal representation of a hexadecimal number.
public static HexToDecimal ( this hex ) : string
hex this Hexadecimal string to convert to decimal.
return string

IsBinary() public static method

Validate if string is a valide binary representation
public static IsBinary ( this binary ) : bool
binary this
return bool

IsHex() public static method

Validate is string is a valide hex representation
public static IsHex ( this hex ) : bool
hex this
return bool

IsUnicode() public static method

Determines if a byte array is unicode
public static IsUnicode ( this data ) : bool
data this Input array
return bool

ToBase64String() public static method

Converts a byte array into a base 64 string
public static ToBase64String ( this data ) : string
data this Input array
return string

ToBinary() public static method

Convert byte array to a binary representation as a string
public static ToBinary ( this data ) : string
data this The byte array to be converted to a string
return string

ToByteArray() public static method

Converts a string to a byte array
public static ToByteArray ( this input, Encoding encodingUsing = null ) : byte[]
input this input string
encodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
return byte[]

ToEncodedString() public static method

Converts a byte array to a string
public static ToEncodedString ( this data, Encoding encodingUsing = null, int index, int count = -1 ) : string
data this input array
encodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
index int The index of the first byte to decode
count int /// Number of bytes starting at the index to convert (use -1 for the entire array starting at the /// index) ///
return string

ToHex() public static method

Converts a byte array to a hexadecimal string representation.
public static ToHex ( this data ) : string
data this Byte array to convert to hexadecimal string.
return string

ToHexNibble() public static method

Convert byte to nibble (4 bit value)
public static ToHexNibble ( this data ) : byte
data this the byte to be converted to a nibble
return byte

ToInt32() public static method

Convert byte array to a 32 bit int
public static ToInt32 ( this data ) : int
data this The byte array to be converted
return int

ToNibbleString() public static method

Convert a byte array into a string with each byte represented as nibbles
public static ToNibbleString ( this data ) : string
data this The byte array to be converted to a string of nibbles
return string