PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.ByteArrayExtensions Class Reference

Provides some extensions useful for byte arrays. More...

Static Public Member Functions

static string ToMD5String (this byte[] data)
 Calculates the md5sum for the provided binary data.
 
static string ToMd5String (this byte[] data)
 Calculates the md5sum for the provided binary data.
 
static string ToUTF8String (this byte[] data)
 Provides a UTF-8 encoded string from the given binary data.
 
static string ToUtf8String (this byte[] data)
 Provides a UTF-8 encoded string from the given binary data.
 
static string ToBase64 (this byte[] data)
 Provides a base64 encoding of the given data. Basically a wrapper around System.Convert.ToBase64String.
 
static MemoryStream ToMemoryStream (this byte[] bytes)
 Converts a byte array to memory stream.
 
static bool StartsWith (this byte[] data, byte[] reference)
 Tests if the byte array being operated on starts with the bytes in the reference array.
 
static byte[] GZip (this byte[] data)
 GZips the input array, producing a new array.
 
static byte[] UnGZip (this byte[] data)
 Decompresses the array of gzipped data.
 
static bool IsGZipped (this byte[] data)
 Indicates whether a byte array has been gzipped.
 

Detailed Description

Provides some extensions useful for byte arrays.

Member Function Documentation

◆ GZip()

static byte[] PeanutButter.Utils.ByteArrayExtensions.GZip ( this byte[]  data)
static

GZips the input array, producing a new array.

Parameters
data
Returns

◆ IsGZipped()

static bool PeanutButter.Utils.ByteArrayExtensions.IsGZipped ( this byte[]  data)
static

Indicates whether a byte array has been gzipped.

Parameters
data
Returns

◆ StartsWith()

static bool PeanutButter.Utils.ByteArrayExtensions.StartsWith ( this byte[]  data,
byte[]  reference 
)
static

Tests if the byte array being operated on starts with the bytes in the reference array.

Parameters
data
reference
Returns
Exceptions
ArgumentNullException

◆ ToBase64()

static string PeanutButter.Utils.ByteArrayExtensions.ToBase64 ( this byte[]  data)
static

Provides a base64 encoding of the given data. Basically a wrapper around System.Convert.ToBase64String.

Parameters
datadata to encode
Returns
base64 representation

◆ ToMD5String()

static string PeanutButter.Utils.ByteArrayExtensions.ToMD5String ( this byte[]  data)
static

Calculates the md5sum for the provided binary data.

Parameters
dataBinary data to hash
Returns
hex-encoded md5sum for the provided data

◆ ToMd5String()

static string PeanutButter.Utils.ByteArrayExtensions.ToMd5String ( this byte[]  data)
static

Calculates the md5sum for the provided binary data.

Parameters
dataBinary data to hash
Returns
hex-encoded md5sum for the provided data

◆ ToMemoryStream()

static MemoryStream PeanutButter.Utils.ByteArrayExtensions.ToMemoryStream ( this byte[]  bytes)
static

Converts a byte array to memory stream.

  • treats null like empty array
Parameters
bytesinput bytes
Returns
MemoryStream wrapping input bytes

◆ ToUTF8String()

static string PeanutButter.Utils.ByteArrayExtensions.ToUTF8String ( this byte[]  data)
static

Provides a UTF-8 encoded string from the given binary data.

Parameters
dataBinary data to encode as a UTF-8 string
Returns
The string representation of the binary data

◆ ToUtf8String()

static string PeanutButter.Utils.ByteArrayExtensions.ToUtf8String ( this byte[]  data)
static

Provides a UTF-8 encoded string from the given binary data.

Parameters
dataBinary data to encode as a UTF-8 string
Returns
The string representation of the binary data

◆ UnGZip()

static byte[] PeanutButter.Utils.ByteArrayExtensions.UnGZip ( this byte[]  data)
static

Decompresses the array of gzipped data.

Parameters
data
Returns

The documentation for this class was generated from the following file: