Show / Hide Table of Contents

Class ByteArrayExtensions

Extension methods for byte[] arrays.

Inheritance
object
ByteArrayExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: GlitchedPolygons.ExtensionMethods
Assembly: GlitchedPolygons.ExtensionMethods.dll
Syntax
public static class ByteArrayExtensions

Methods

| Improve this Doc View Source

GetFileSizeString(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 string that represents the passed byte[] array's length (string.Empty if the array was null).

| Improve this Doc View Source

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 byte[] array to hash.

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!

| Improve this Doc View Source

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 byte[] array to hash.

bool toLowercase

Should the output hash string be lowercased?.

Returns
Type Description
string

SHA1 of the input string.

Remarks

Do not use MD5 for anything security-related! Do NOT hash passwords using this!

| Improve this Doc View Source

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 byte[] array to hash.

bool toLowercase

Should the output hash string be lowercased?.

Returns
Type Description
string

SHA256 of the input string.

| Improve this Doc View Source

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 byte[] array to hash.

bool toLowercase

Should the output hash string be lowercased?.

Returns
Type Description
string

SHA384 of the input string.

| Improve this Doc View Source

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 byte[] array to hash.

bool toLowercase

Should the output hash string be lowercased?.

Returns
Type Description
string

SHA512 of the input string.

| Improve this Doc View Source

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 = padding characters be omitted?

Returns
Type Description
string

The Base64-encoded string.

| Improve this Doc View Source

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.

| Improve this Doc View Source

UTF8GetString(byte[])

Returns Encoding.UTF8.GetString(byte[]).

Declaration
public static string UTF8GetString(this byte[] bytes)
Parameters
Type Name Description
byte[] bytes

The byte[] array to convert.

Returns
Type Description
string

Returns Encoding.UTF8.GetString(byte[])

  • Improve this Doc
  • View Source
Back to top Generated by DocFX