Giter Club home page Giter Club logo

miniguid's Introduction

MiniGuid

A Guid value-type that converts to and from 26-char alphabetic strings - like ShortGuid, but better.

Good for URLs!

Readability

MiniGuid.ToString() Guid.ToString()
xEykoBBxSwSuDJBZEzNOSFFIMU 6fa7b0bf-6577-4e99-8f73-f64e867fe236
EutvfDtJywUKveRWSFBbsCHpyL f65227f5-c563-4a9c-9170-67f619702fc5
BukxYWEvDMreXSDoaLSzRDRhkH 437915dd-e9d5-48a2-b3ae-015995f56751
COKwlTfEmgwuRGyfyNMtuPIlNb b46509e2-61be-45ad-8305-c1cd3a244b39
QxLKubVCxzzuTSKvxxizlZfyyg 054aca55-befc-4673-b095-bdd195ccb8c6

Usage

using MiniGuids;

var miniGuid = MiniGuid.NewGuid();

//implicit conversions (and vice-versa too)
string someString = miniGuid;
Guid someGuid = miniGuid;

//explicit stringifying and parsing
var str = miniGuid.ToString();
var sameMiniGuid = MiniGuid.Parse(str);

//works out-of-the-box with Json.NET, MVC, etc. via TypeConverters
var json = JsonConvert.SerializeObject(new { miniGuid }); //{ "miniGuid": "aaaaaBBBBBcccccDDDDDeeeeeF" }

FAQ

What about ShortGuid?

It's all about readability: ShortGuid compresses to 22 chars by also including numbers and two special characters (_ and -) - this leads to complicated-looking identifiers like _-9g5YdI9A27c_a-2FC00ebQ2.

MiniGuid in comparison always outputs a blob of letters - all in the same character class, and without strange pepperings of underscores etc. It's a trade-off - four more characters, but more regular and digestable: QxLKubVCxzzuTSKvxxizlZfyyg.

Also (not insignificantly) MiniGuid is nicely hosted on GitHub, nicely packaged with implicit conversions etc, and (drumroll) compatible with .NET Standard.

miniguid's People

Contributors

jasonholloway avatar lgoudriaan 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.