Giter VIP home page Giter VIP logo

kingutils's Introduction

KingUtils

A collection of miscellaneous extension methods and utility classes.

Features

Here's a quick overview of what the library adds:

// Base16 encoding/decoding:
var base16String = Base16.Encode(byteArrayOrByteSpan);
var base16Bytes = Base16.Decode(base16String);

// Base32 encoding/decoding (Crockford, WordSafe, Rfc4648):
var base32String = Base32.Crockford.Encode(byteArrayOrByteSpan);
var base32Bytes = Base32.Crockford.Decode(base32String);

// String (and string-related) extensions:
var truncatedString = longString.Truncate(80);
var truncatedStringWithSuffix = longString.Truncate(80, "...");
var joinedString = (new[] { "one", "two", "three" }).ToJoinedString(coordinatingConjunction: "and", serialComma: true); // "one, and two, and three"

// Simple string encryption and decryption:
var encryptedValue = CryptoHelper.EncryptString("string to encrypt", "password", 16, 100_000, HashAlgorithmName.SHA256);
var decryptedValue = CryptoHelper.DecryptString(encryptedValue, "password"); // Salt, iterations, and hash algorithm are encapsulated in the encrypted value, so don't need to provide them.

// Date and time extensions:
var humanReadableDateTime = dateTime.ToRelativeHumanReadableString(); // "4 hours and 15 minutes ago"
var humanReadableTimeSpan = timeSpan.ToHumanReadableString(); // "8 minutes and 20 seconds"

// Byte array extensions:
var hexString = byteArray.ToHexString();

// Dictionary extensions:
var value = dictionary.GetValueOrDefault("key", defaultValue);

// Task extensions:
task.FireAndForget();

// Enumerable extension polyfills for NET5 and earlier.
var chunks = enumerable.Chunk(4);

Installation

Just grab it from NuGet

PM> Install-Package KingUtils
$ dotnet add package KingUtils

License and copyright

Copyright Matthew King.

Distributed under the MIT License.

Refer to license.txt for more information.

kingutils's People

Contributors

matthewking avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.