Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Uid] add AbstractUid and interop with base-58/32/RFC4122 encodings#36074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:uuid-abstract
Mar 15, 2020

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedMar 14, 2020
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

This PR provides a baseAbstractUid class that is shared byUuid andUlid.

It adds new methods that provide interoperability between all types of UIDs but also between different encodings of UIDs:

  • toBase58() using thebitcoin alphabet - that's 22 chars aka "short-ids" - case sensitive
  • toBase32() usingCrockford's alphabet - 26 chars ids - case insensitive
  • toRfc4122() to represent as a UUID-formatted string - 36 chars

This adds totoBinary() and tofromString(), the latter being able to cope with any of the 4 representations to create any kind of UIDs.

@javiereguiluz
Copy link
Member

I don't know the future plans of this component (will we keep adding other popular UIDs?) but this doesn't look future-proof to me. Any method that we add here could look outdated or unused in other future UID generators.

This reminds me to thesalt property of password encoders. It was obvious to add it to an interface because every encoder uses it ... until some stopped using it and the interface no longer looked good for modern encoders.

@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedMar 14, 2020
edited
Loading

All serious id schemes use 128-bit identifiers, which is wide enough to deal with any use cases for the foreseeable future. Then, base58, base32, uuid-format are 3 widely used representation of 128-bit numbers. They fit various needs: 58 bit for compactness, 32 bit for case insensitivity, uuid-format for interop with e.g. DB storages.

My opinion is that all three of them are generic enough to land in the component.

Your comparison with salted-encoders is good: wedid add them to the component because that's what ppl were widely using at the time. We don't know the future but we know these encoding schemes are widely used and have good reasons to remain so.

@nicolas-grekas
Copy link
MemberAuthor

will we keep adding other popular UIDs?

UUIDv6 would make sense. I'm not sure about others. I think we should work on integrating with Doctrine before considering other schemes. Then future will tell, there are no plans...

@fabpot
Copy link
Member

Can you rebase?

@nicolas-grekas
Copy link
MemberAuthor

Now rebased.

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitade47dd intosymfony:masterMar 15, 2020
@nicolas-grekasnicolas-grekas deleted the uuid-abstract branchMarch 15, 2020 10:41
Tobion added a commit to Tobion/symfony that referenced this pull requestMar 15, 2020
nicolas-grekas added a commit that referenced this pull requestMar 15, 2020
This PR was merged into the 5.1-dev branch.Discussion----------[UID] remove unused property| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       || License       | MIT| Doc PR        |leftover from#36074Commits-------901e62a remove unused uuid property
symfony-splitter pushed a commit to symfony/uid that referenced this pull requestMar 15, 2020
@nicolas-grekasnicolas-grekas modified the milestones:next,5.1May 4, 2020
@fabpotfabpot mentioned this pull requestMay 5, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
5.1
Development

Successfully merging this pull request may close these issues.

4 participants
@nicolas-grekas@javiereguiluz@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp