进一步减少 uuid 以制作短字符串 [英] cutdown uuid further to make short string
问题描述
我需要为给定的唯一字符串生成唯一的记录 ID.
I need to generate unique record id for the given unique string.
我尝试使用 uuid 格式,这似乎不错.
I tried using uuid format which seems to be good.
但我们觉得这是冗长的.
But we feel that is lengthly.
所以我们需要将 uuid 字符串 9f218a38-12cd-5942-b877-80adc0589315 减少到更小.通过删除-",我们可以节省 4 个字符.从 uuid 中删除最安全的部分是什么?我们不需要通用唯一的 id,但我们喜欢使用 uuid 作为来源,但要减少字符串.
so we need to cutdown the uuid string 9f218a38-12cd-5942-b877-80adc0589315 to smaller. By removing '-' we can save 4 chars. What is the safest part to remove from uuid? We don't need universally unique id but we like to use uuid as a source but cut down strings.
我们需要特定于站点/数据库(SQL Server/ADO.NET 数据服务)的唯一 ID.
We need unique id specific to site/database (SQL Server/ADO.NET Data services).
任何语言的任何想法或样本都可以
Any idea or sample from any language is fine
提前致谢
推荐答案
为什么不直接将其转换为 base 64 字符串?您可以通过这种方式将其减少到 22 个字符.
Why not instead just convert it to a base 64 string? You can cut it down to 22 characters that way.
这篇关于进一步减少 uuid 以制作短字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!