Skip to content

schochastics/shortuuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shortuuid

R-CMD-check

The goal of shortuuid is to generate and translate standard UUIDs into shorter - or just different - formats and back. Inspired by short-uuid and a post on fosstodon

Installation

You can install the development version of shortuuid like so:

remotes::install_github("schochastics/shortuuid")

Example

This is a basic example which shows you how to solve a common problem:

library(shortuuid)
# generate random uuids
ids <- generate_uuid(n = 5)
ids
#> [1] "bcebf5e3-2ee8-46f4-a31a-a92392218067"
#> [2] "672311ef-ffb7-4ccf-9d32-43ea69366b59"
#> [3] "ba041d3b-2b5f-4973-843a-5af11d3e0d83"
#> [4] "33a2c8b1-af02-41bf-bf00-1de387bfa160"
#> [5] "83f32d4a-dee1-4f37-b9e1-2fbf4263af71"
is.uuid(ids)
#> [1] TRUE TRUE TRUE TRUE TRUE
# alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
b58 <- uuid_to_bitcoin58(ids)
b58
#> [1] "QL5HS5bUkCksVHSdZRARxi" "DjgDY7cqTkMb4QeC2bbAHe" "PyGGrbPiqaQJZ3wkuZ3dbp"
#> [4] "7Npbe4WM8YKcSuz9YXCmWf" "HJ38h8nL729Sg9YpoFcbUt"
# alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
f58 <- uuid_to_flickr58(ids)
f58
#> [1] "pk5hr5AtKcKSuhrCyqaqXH" "dJFdx7BQsKmA4pDc2AAahD" "oYggRAoHQzpiy3WKUy3CAP"
#> [4] "7nPAD4vm8xjBrUZ9xwcLvE" "hi38G8Mk729rF9xPNfBAtT"
# convert back
bitcoin58_to_uuid(b58)
#> [1] "bcebf5e3-2ee8-46f4-a31a-a92392218067"
#> [2] "672311ef-ffb7-4ccf-9d32-43ea69366b59"
#> [3] "ba041d3b-2b5f-4973-843a-5af11d3e0d83"
#> [4] "33a2c8b1-af02-41bf-bf00-1de387bfa160"
#> [5] "83f32d4a-dee1-4f37-b9e1-2fbf4263af71"
flickr58_to_uuid(f58)
#> [1] "bcebf5e3-2ee8-46f4-a31a-a92392218067"
#> [2] "672311ef-ffb7-4ccf-9d32-43ea69366b59"
#> [3] "ba041d3b-2b5f-4973-843a-5af11d3e0d83"
#> [4] "33a2c8b1-af02-41bf-bf00-1de387bfa160"
#> [5] "83f32d4a-dee1-4f37-b9e1-2fbf4263af71"

Addendum

Code to generate uuids taken from @rkg8

About

No description, website, or topics provided.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published