8000 GitHub - yogthos/alpha-id: creates a short alphanumeric ID from a numeric ID
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

yogthos/alpha-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alpha-id

A Clojure library for convering numbers into short alphanumeric IDs.

Clojars Project

Usage

The number is coverted to an alphanumeric string and back using the encode the decode functions respectively. The functions accept the dictionary as their first parameter and the value as the second.

Helper functions are provided for the following dictionary sizes:

  • encode-16/decode-16
  • encode-32/decode-32
  • encode-64/decode-64
  • encode-89/decode-89

Using a larger dictionary results in a shorter ID being generated.

(use 'alpha-id.core)

(def dict [\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \A \B \C \D \E \F])
(encode dict 123456) ;=> "1E240"
(decode dict "1E240") ;=> 123456

(encode-64 9007199254740992) ;=>"fFgnDxSe8"
(decode-64 "fFgnDxSe8") ;=> 9007199254740992

License

Copyright © 2015 Dmitri Sotnikov

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

creates a short alphanumeric ID from a numeric ID

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0