Git Product home page Git Product logo

data-cuid's Introduction

Actions Status Coverage Status MetaCPAN Release Build Status

NAME

Data::Cuid - collision-resistant IDs

SYNOPSIS

use Data::Cuid qw(cuid slug);

my $id   = cuid();          # cjg0i57uu0000ng9lwvds8vb3
my $slug = slug();          # uv1nlmi

DESCRIPTION

Data::Cuid is a port of the cuid JavaScript library for Perl.

Collision-resistant IDs (also known as cuids) are optimized for horizontal scaling and binary search lookup performance, especially for web or mobile applications with a need to generate tens or hundreds of new entities per second across multiple hosts.

Data::Cuid does not export any functions by default.

FUNCTIONS

cuid

my $cuid = cuid();

Produce a cuid as described in the original JavaScript implementation. This cuid is safe to use as HTML element IDs, and unique server-side record lookups.

slug

my $slug = slug();

Produce a shorter ID in nearly the same fashion as "cuid". This slug is good for things like URL slug disambiguation (i.e., example.com/some-post-title-<slug>) but is absolutely not recommended for database unique IDs.

SEE ALSO

Cuid

LICENSE

The MIT License (MIT)

Copyright (C) Zak B. Elep.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

AUTHOR

Zak B. Elep [email protected]

Original cuid JavaScript library maintained by Eric Elliott

data-cuid's People

Contributors

zakame avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

data-cuid's Issues

XS Speedup for _base36 function

Hi!

I wrote (as an attempt to write some XS module) xs version of _base36 function.

Here is benchmark.

Results

        Rate    pp    xs
pp   88889/s    --  -92%
xs 1098901/s 1136%    --

So, will You accept pull request with xs implementation of base36?
Thanks in advance.

Cuid standard is deprecated.

Due to security concerns (which also exist in database auto-increment ids, uuid/guid, and most other id standards), the Cuid standard is now deprecated in favor of Cuid2.

fingerprint component length can overflow beyond the allocated 4 characters

Since _encode_base36() uses $padding only as a minimum length (not also a right-anchored maximum length, as pad() does in the JS implementation), and since _fingerprint() does not build its value using substr(...,-2) of the encoded pid and hostname values, the fingerprint field will overflow and exceed 4 characters if either value exceeds 36² - 1.

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.