System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework.Extensions SystemLibrary.Common.Framework.Net.dll

    Byte array extensions

    ByteArrayExtensions

    public static class ByteArrayExtensions

    Inheritance
    object
    ByteArrayExtensions
    Examples
    Arguments
    X

    Methods

    Byte array extensions

    public static string Compress(this byte[] bytes)

    X
    Methods arguments
    Type Name Description
    byte[] bytes
    X
    Type Description
    string

    Byte array extensions

    public static string Decompress(this byte[] bytes, Encoding encoding = null)

    X
    Methods arguments
    Type Name Description
    byte[] bytes
    Encoding encoding
    X
    Type Description
    string

    Return a base64 string of the bytes

    Remarks
    X

    If you dont need base64 format, .Obfuscating() method is faster if data is less than ~400KB

    public static string ToBase64(this byte[] bytes)

    X
    var bytes = "hello world".GetBytes();
    var base64string = bytes.ToBase64();
    X
    Methods arguments
    Type Name Description
    byte[] bytes
    X
    Type Description
    string

    Returns Base64 string or null or empty if input was so

    Returns a hash string of the bytes

    Remarks
    X

    If data is larger than ~200 bytes then .ToSha1Hash() is faster

    public static string ToMD5Hash(this byte[] bytes)

    X
    var bytes = "hello world".GetBytes();
    var md5string = bytes.ToMD5Hash();
    X
    Methods arguments
    Type Name Description
    byte[] bytes
    X
    Type Description
    string

    Md5 hash or null or empty if input was so

    Returns a sha1 hash string of the bytes

    Remarks
    X

    If data is less than ~200 bytes then .ToMD5Hash() is faster

    public static string ToSha1Hash(this byte[] bytes)

    X
    var bytes = "hello world".GetBytes();
    var sha1string = bytes.ToSha1Hash();
    X
    Methods arguments
    Type Name Description
    byte[] bytes
    X
    Type Description
    string

    A Sha1 hash or null or empty if input is null or empty

    Returns a sha 256 hash string of the bytes

    Remarks
    X

    If input is null or empty it returns null or empty string

    public static string ToSha256Hash(this byte[] bytes)

    X
    var bytes = "hello world".GetBytes();
    var sha256string = bytes.ToSha256Hash();
    X
    Methods arguments
    Type Name Description
    byte[] bytes
    X
    Type Description
    string

    A Sha256 hash, or null or empty if input was so

    Return a text representation of the byte array

    public static string ToText(this byte[] bytes, Encoding encoding = null)

    X
    var bytes = "hello world".GetBytes();
    var text = bytes.ToText();  //text == hello world
    X
    Methods arguments
    Type Name Description
    byte[] bytes
    Encoding encoding
    X
    Type Description
    string

    Text, or null or empty if input was null or empty

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework