Show / Hide Table of Contents

Class StringExtensions

Extension methods for all strings.

Inheritance
object
StringExtensions
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 StringExtensions

Methods

| Improve this Doc View Source

FromBase64String(string)

Base64-decodes a string into a UTF-8 string.

Declaration
public static string FromBase64String(this string str)
Parameters
Type Name Description
string str

string to decode.

Returns
Type Description
string

string

| Improve this Doc View Source

FromBase64UrlString(string)

Base64-URL-decodes a string into a UTF-8 string.

Declaration
public static string FromBase64UrlString(this string str)
Parameters
Type Name Description
string str

string to decode.

Returns
Type Description
string

string

| Improve this Doc View Source

IsASCII(string)

Checks whether a given string only contains ASCII characters or not.

null or empty strings 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 string only contained ASCII chars or not. If the string was empty or null, true is returned.

| Improve this Doc View Source

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 string is valid or not.

| Improve this Doc View Source

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!

| Improve this Doc View Source

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 string to check.

Returns
Type Description
bool

!string.IsNullOrEmpty(str)

| Improve this Doc View Source

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 string to check.

Returns
Type Description
bool

string.IsNullOrEmpty(str)

| Improve this Doc View Source

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 string to open.

| Improve this Doc View Source

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 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(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 string be lowercased?.

Returns
Type Description
string

SHA256 of the input string.

| Improve this Doc View Source

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 string be lowercased?.

Returns
Type Description
string

SHA384 of the input string.

| Improve this Doc View Source

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 string be lowercased?.

Returns
Type Description
string

SHA512 of the input string.

| Improve this Doc View Source

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

string

| Improve this Doc View Source

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

string

| Improve this Doc View Source

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[]

Convert.FromBase64String(b64)

| Improve this Doc View Source

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[]

Convert.FromBase64String(b64)

| Improve this Doc View Source

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

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