Class StringExtensions
Extension methods for all string
s.
Inherited Members
Namespace: GlitchedPolygons.ExtensionMethods
Assembly: GlitchedPolygons.ExtensionMethods.dll
Syntax
public static class StringExtensions
Methods
| Improve this Doc View SourceFromBase64String(string)
Declaration
public static string FromBase64String(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | string to decode. |
Returns
Type | Description |
---|---|
string |
FromBase64UrlString(string)
Declaration
public static string FromBase64UrlString(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | string to decode. |
Returns
Type | Description |
---|---|
string |
IsASCII(string)
Checks whether a given string
only contains ASCII characters or not.
null
or empty string
s return true
!.
Declaration
public static bool IsASCII(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | The string to check. |
Returns
Type | Description |
---|---|
bool | Whether the checked |
IsValidEmail(string)
Checks if a given string
is a valid email address or not.
Declaration
public static bool IsValidEmail(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | The email address to validate. |
Returns
Type | Description |
---|---|
bool | Whether the given email address |
MD5(string, bool)
Computes the MD5 hash of a string
.
Declaration
public static string MD5(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text 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!
NotNullNotEmpty(string)
Returns true
when the passed string
is not null
or empty; false
otherwise.
Declaration
public static bool NotNullNotEmpty(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | The |
Returns
Type | Description |
---|---|
bool |
|
NullOrEmpty(string)
Returns whether the passed string is null
or empty.
Declaration
public static bool NullOrEmpty(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | The |
Returns
Type | Description |
---|---|
bool |
|
OpenUrlInBrowser(string)
Opens the string
URL in the browser.
Declaration
public static void OpenUrlInBrowser(this string url)
Parameters
Type | Name | Description |
---|---|---|
string | url | The URL |
SHA1(string, bool)
Computes the SHA1 of a string
.
Declaration
public static string SHA1(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to hash. |
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(string, bool)
Computes the SHA256 of a string
.
Declaration
public static string SHA256(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to hash. |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA256 of the input string. |
SHA384(string, bool)
Computes the SHA384 of a string
.
Declaration
public static string SHA384(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to hash. |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA384 of the input string. |
SHA512(string, bool)
Computes the SHA512 of a string
.
Declaration
public static string SHA512(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to hash. |
bool | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
string | SHA512 of the input string. |
ToBase64String(string)
Converts a string to a Base64-encoded string of its UTF-8 bytes.
Declaration
public static string ToBase64String(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | string to encode. |
Returns
Type | Description |
---|---|
string |
ToBase64UrlString(string)
Converts a string to a Base64-URL-encoded string of its UTF-8 bytes.
Declaration
public static string ToBase64UrlString(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | string to encode. |
Returns
Type | Description |
---|---|
string |
ToBytesFromBase64(string)
Converts a base64-encoded string to bytes, appending '=' padding characters to it if needed.
Declaration
public static byte[] ToBytesFromBase64(this string b64)
Parameters
Type | Name | Description |
---|---|---|
string | b64 | The string to convert. |
Returns
Type | Description |
---|---|
byte[] |
|
ToBytesFromBase64Url(string)
Converts a base64-URL-encoded string to bytes, appending '=' padding characters to it if needed.
Declaration
public static byte[] ToBytesFromBase64Url(this string b64url)
Parameters
Type | Name | Description |
---|---|---|
string | b64url | The string to convert. |
Returns
Type | Description |
---|---|
byte[] |
|
UTF8GetBytes(string)
Encodes a string
to bytes using Encoding.UTF8
.
Declaration
public static byte[] UTF8GetBytes(this string text)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to encode. |
Returns
Type | Description |
---|---|
byte[] | The encoded |