Class ByteArrayExtensions
Extension methods for byte[]
arrays.
Inherited Members
Namespace: GlitchedPolygons.ExtensionMethods
Assembly: GlitchedPolygons.ExtensionMethods.dll
Syntax
public static class ByteArrayExtensions
Methods
| Improve this Doc View SourceGetFileSizeString(byte[])
Gets the byte[]
array's human readable file size string (e.g. "5 KB" or "20 MB").
Declaration
public static string GetFileSizeString(this byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The bytes (for example a file whose size you want to retrieve in a human readable way). |
Returns
Type | Description |
---|---|
string | A human readable file size |
MD5(byte[], bool)
Computes the MD5 hash of a byte[]
array.
Declaration
public static string MD5(this byte[] bytes, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The |
bool | toLowercase | Should the output hash be lowercased? |
Returns
Type | Description |
---|---|
string | MD5 hash of the input string. |
Remarks
Do not use MD5 for anything security-related! Do NOT hash passwords using this!
SHA1(byte[], bool)
Computes the SHA1 of a byte[]
array.
Declaration
public static string SHA1(this byte[] bytes, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA1 of the input string. |
Remarks
Do not use MD5 for anything security-related! Do NOT hash passwords using this!
SHA256(byte[], bool)
Computes the SHA256 of a byte[]
array.
Declaration
public static string SHA256(this byte[] bytes, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA256 of the input string. |
SHA384(byte[], bool)
Computes the SHA384 of a byte[]
array.
Declaration
public static string SHA384(this byte[] bytes, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA384 of the input string. |
SHA512(byte[], bool)
Computes the SHA512 of a byte[]
array.
Declaration
public static string SHA512(this byte[] bytes, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA512 of the input string. |
ToBase64String(byte[], bool)
Converts a byte[]
array to a Base64-encoded string with optional removal of the padding '=' characters.
Declaration
public static string ToBase64String(this byte[] bytes, bool omitPaddingChars = false)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The bytes to encode. |
bool | omitPaddingChars | Should the |
Returns
Type | Description |
---|---|
string | The Base64-encoded string. |
ToBase64UrlString(byte[])
Converts a byte[]
array to a Base64-URL-encoded string.
Declaration
public static string ToBase64UrlString(this byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The bytes to encode. |
Returns
Type | Description |
---|---|
string | The Base64-URL-encoded string. |
UTF8GetString(byte[])
Returns Encoding.UTF8.GetString(byte[])
.
Declaration
public static string UTF8GetString(this byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The |
Returns
Type | Description |
---|---|
string | Returns |