Git Product home page Git Product logo

readable's Introduction

Readable

Readable is a simple go package for generating fluent UUIDs.

Readables are UUIDs that are converted to a grammatically correct sentence. This makes them easy to remember and share, and adds spice to your life. You can convert a readable to a UUID and vice versa.

flowchart TD
U(( UUID )) <--> F(( Readable ))

F -- Hash --> S[[ Smol ]]
U -- Hash --> S
Loading

Examples

128-bit UUIDs

Corry Allie Evita the steerer of Bascom dreamed Lindsy Gunar Marlette and 2 short mice

Mira Corey Cord the morrow of Cedars prays Magdalene Abie Freya and 32 bright alpacas

Claire Gordon MacPherson the playmaker of Canova emptys Ilsa Alonzo Deery and 19 cute pheasants

Candis Duky Harriman the corncrib of Blevins deserted Caye Gardie Osbert and 21 deep moles

Doe Decca Giuliana the plea of Analomink dreams Lyndell Gregorio Mokas and 6 thirsty squirrels

32-bit Smol IDs

39 expensive ewes stealthily drove

24 hungry coyotes fondly sang

65 small bees kookily sang

3 high rooks greatly sings

43 low jackals needily sang

Features

  • Built on UUID v4
  • Optionally pass your UUID to generate a unique sentence
  • 128 Bit Crypto Secure
  • Grammatically correct sentences
  • Easy to remember
  • Has a Shakespeare feeling
  • Universally Unique Identifier
  • Generate Low Entropy 32 Bit Tokens

Installation

go get github.com/nascarsayan/readable

Usage

Create readable UUIDs

package main

import (
  "fmt"

  guid "github.com/google/uuid"
  "github.com/nascarsayan/readable"
)

sentence := readable.New()
fmt.Println(uid) 
// Dari Findlay Joaquin the pathos of Bandytown 
// preserves Daisy Cletis Alarice and 29 salty hogs

// + Interconvert between UUIDv4 and readable.

uuid := guid.New()
fmt.Println(uuid)
// 92e39d12-d0a6-4953-8999-edbf85f7ad66
sentence = readable.FromUUID(uuid)
fmt.Println(sentence)
// Janot Boniface Harriet the contestant of Broseley 
// preserved Carrissa Gayler Hahnert and 31 windy gnus

hex, err := readable.ToUUID(sentence)
if err != nil {
  fmt.Errorf("error converting readable to uuid: %v", err)
}
fmt.Println(hex)
// 92e39d12-d0a6-4953-8999-edbf85f7ad66

Create smol IDs from UUIDs or readables

package main

import (
  "fmt"

  "github.com/nascarsayan/readable"
)

long := readable.New()
fmt.Println(long)
// Allix Ernestus Matthieu the millwright of Cementon 
// dislikes Nerissa Fairfax Drucilla and 13 old aardvarks
short, err := readable.Smol(long)
if err != nil {
  fmt.Errorf("error converting uuid to smol: %v", err)
}
fmt.Println(short)
// 64 light doves lively ran

// Check if a smol ID is the hash of a readable
readable.VerifySmolWithReadable(short, long) // true
readable.VerifySmolWithReadable(short, readable.New()) // false

// Check if a smol ID is the hash of a UUID
uid := readable.ToUUID(sentence)
readable.VerifySmolWithUUID(short, uid) // true

Credits

readable's People

Contributors

nascarsayan avatar

Stargazers

Gergely Radics avatar Tim Kersey avatar Debdut Karmakar avatar

Watchers

Debdut Karmakar 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.