Skip to content

Converts a string, e.g. a hash, into a human-friendly phrase, akin to diceware

Notifications You must be signed in to change notification settings

ChronSyn/csharp-diceware

Repository files navigation

C# Diceware - Human-friendly hashes

This is a CSharp (.NET Core) Diceware library, commonly known as 'human friendly hashes'.

It takes a string (e.g. a hash) and converts it to a phrase according to a specific format.

It's not available on nuget at this time, but simply copying the .cs files from this repo into a folder, and then using Diceware; should be sufficient.

This library is literally a translation from the JS library 'hashwords' (https://github.com/jjt/hashwords)

There's a few diceware / human-friendly-hash libs already out there for C#, but none of them allowed you to control the input.

This is a 1-way function, and it is not possible to get the original hash back from a diceware hash generated by this library. With that said, I make no promises about it's cryptographic security.

Usage

using Diceware;

public string GenerateDicewareString(){
    Diceware.Diceware DW = new Diceware.Diceware();
    return DW.GenerateDicewareString("WEAR_A_MASK", "adj adj noun animal", 8);

    // Returns 4 words which are at least 8 characters in length in the format 'adjective adjective noun animal'
}

Use cases

If you're generating a hash based upon defined unique values (e.g. a hardware device serial number), this library takes that hash that you'll probably never remember, and turns it into something you will remember.

Why?

I was attempting to rewrite a node project in C#, for fun, to see if it was possible, and to help practice my C#. Part of that project needed the functionality provided here. No C# library with this functionality existed already, so I converted an existing JS library.

PR's?

By all means, open a PR. I can't promise that I'll be watching for PR's to this repo or that they'll be merged.

Fork the library and adapt it. Use it freely.

About

Converts a string, e.g. a hash, into a human-friendly phrase, akin to diceware

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages