Class StringExtensions
Extension methods for all string
s.
Inheritance
Inherited Members
Namespace: GlitchedPolygons.ExtensionMethods
Assembly: GlitchedPolygons.ExtensionMethods.dll
Syntax
public static class StringExtensions
Methods
| Improve this Doc View SourceBCrypt(String, Int32)
Hashes the string
using the BCrypt algorithm.
Only use BCryptVerify(String, String) for verifying/comparing!
Declaration
public static string BCrypt(this string text, int logRounds = 12)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The |
System.Int32 | logRounds | The log2 of the number of rounds of hashing to apply. The work factor increases as (2 ** logRounds). The higher, the safer, the slower. |
Returns
Type | Description |
---|---|
System.String | The hashed |
BCrypt_Enhanced(String, Int32)
Hashes the string
using SHA384 + BCrypt algorithm.
Only use BCryptVerify_Enhanced(String, String) for verifying/comparing!
Declaration
public static string BCrypt_Enhanced(this string text, int logRounds = 12)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The |
System.Int32 | logRounds | The log2 of the number of rounds of hashing to apply. The work factor increases as (2 ** logRounds). The higher, the safer, the slower. |
Returns
Type | Description |
---|---|
System.String | The hashed |
BCryptVerify(String, String)
Verifies a BCrypted string
(obtained using BCrypt(String, Int32)) against its plaintext counterpart.
Declaration
public static bool BCryptVerify(this string bcryptedString, string plaintextToCompare)
Parameters
Type | Name | Description |
---|---|---|
System.String | bcryptedString | The BCrypt hash of the |
System.String | plaintextToCompare | The plaintext |
Returns
Type | Description |
---|---|
System.Boolean | Whether the plaintext string + hash could be verified. |
BCryptVerify_Enhanced(String, String)
Verifies a BCrypted string
that was obtained using BCrypt_Enhanced(String, Int32).
Declaration
public static bool BCryptVerify_Enhanced(this string bcryptedString, string plaintextToCompare)
Parameters
Type | Name | Description |
---|---|---|
System.String | bcryptedString | The BCrypt hash of the |
System.String | plaintextToCompare | The plaintext |
Returns
Type | Description |
---|---|
System.Boolean | Whether the plaintext string + hash could be verified. |
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 |
---|---|---|
System.String | str | The string to check. |
Returns
Type | Description |
---|---|
System.Boolean | 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 |
---|---|---|
System.String | str | The email address to validate. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the given email address |
MD5(String, Boolean)
Computes the MD5 hash of a string
.
Declaration
public static string MD5(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to hash. |
System.Boolean | toLowercase | Should the output hash be lowercased? |
Returns
Type | Description |
---|---|
System.String | MD5 hash of the input string. |
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 |
---|---|---|
System.String | str | The |
Returns
Type | Description |
---|---|
System.Boolean |
|
NullOrEmpty(String)
Returns whether the passed string is null
or empty.
Declaration
public static bool NullOrEmpty(this string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The |
Returns
Type | Description |
---|---|
System.Boolean |
|
OpenUrlInBrowser(String)
Opens the string
URL in the browser.
Declaration
public static void OpenUrlInBrowser(this string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The URL |
SHA1(String, Boolean)
Computes the SHA1 of a string
.
Declaration
public static string SHA1(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to hash. |
System.Boolean | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
System.String | SHA1 of the input string. |
SHA256(String, Boolean)
Computes the SHA256 of a string
.
Declaration
public static string SHA256(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to hash. |
System.Boolean | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
System.String | SHA256 of the input string. |
SHA384(String, Boolean)
Computes the SHA384 of a string
.
Declaration
public static string SHA384(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to hash. |
System.Boolean | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
System.String | SHA384 of the input string. |
SHA512(String, Boolean)
Computes the SHA512 of a string
.
Declaration
public static string SHA512(this string text, bool toLowercase = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to hash. |
System.Boolean | toLowercase | Should the output hash |
Returns
Type | Description |
---|---|
System.String | SHA512 of the input string. |
UTF8GetBytes(String)
Encodes a string
to bytes using Encoding.UTF8
.
Declaration
public static byte[] UTF8GetBytes(this string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to encode. |
Returns
Type | Description |
---|---|
System.Byte[] | The encoded |