thibaultmeyer / cuid-java Goto Github PK
View Code? Open in Web Editor NEWCollision-resistant ids optimized for horizontal scaling and performance
License: MIT License
Collision-resistant ids optimized for horizontal scaling and performance
License: MIT License
Is your feature request related to a problem? Please describe.
When the use-case is simply something like username or URL disambiguation where you don't need strong uniqueness guarantees.
Describe the solution you'd like
Parameterized Length in CUID 2 https://github.com/paralleldrive/cuid2#parameterized-length
Describe alternatives you've considered
N/A
Additional context
official javascript example of same
import { init } from '@paralleldrive/cuid2';
const length = 10; // 50% odds of collision after ~51,386,368 ids
const cuid = init({ length });
console.log(cuid()); // nw8zzfaa4v
Describe the bug
I am unsure if this implementation is the same algorithm as the original.
To Reproduce
The entropy is computed differently:
cuid-java/src/main/java/io/github/thibaultmeyer/cuid/CUID.java
Lines 265 to 275 in c55aa79
The hash is computed differently:
cuid-java/src/main/java/io/github/thibaultmeyer/cuid/CUID.java
Lines 283 to 292 in c55aa79
The alphabet is accessed differently:
https://github.com/ai/nanoid?tab=readme-ov-file
random % alphabet is a popular mistake [...] [t]he distribution will not be even; there will be a lower chance for some symbols to appear compared to others.
I found this repo mentioned in https://usecuid.org/. It would be great if this library could be automatically deployed to Maven Central repo, so that people could reference it as a Maven dependency.
Due to security concerns (which also exist in database auto-increment ids, uuid/guid, and most other id standrads), the Cuid standard is now deprecated in favor of Cuid2.
Is your feature request related to a problem? Please describe.
https://github.com/paralleldrive/cuid2#validation
import { createId, isCuid } from '@paralleldrive/cuid2';
console.log(
isCuid(createId()), // true
isCuid('not a cuid'), // false
);
Describe the solution you'd like
Java version of https://github.com/paralleldrive/cuid2/pull/38/files
Describe alternatives you've considered
N/A
Additional context
paralleldrive/cuid2#37
paralleldrive/cuid2#38
https://github.com/paralleldrive/cuid2/releases/tag/v2.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.