C#中如何转换字符串中的唯一ID [英] C# how to convert string in to unique ID
问题描述
让我们假设我们有字符串名称=stackoverflow.com;
如何将此字符串INT转换为一个唯一的ID或某种哈希的。 (无MD5,因为它太大了),它不应该是随机
我会想有这样的事情
请注意字符串本身太大了,我想知道如果字符串可以写短。在字母,数字和符号的组合
f¤k^§〜7天?Æ
这是不限制你的域名是不可能的。有无穷多个字符串
和等都不能injectively映射到任何有限集。因此,唯一性是不可能的。
如果你真的想为字符串
的唯一标识符,使用字符串
本身。
let assume we have string name = "stackoverflow.com";
how to convert this string int to a unique ID or some sort of Hash. (no md5 because its too big) and it should not be random
i will like to have something like this
Please note string itself is too big I would like to know if the string can be written shorter. in an combination of letters, numbers and symbols
f¤k^§~7d?Æ
This is impossible without restricting your domain. There are infinitely many string
s and so can't be mapped injectively into any finite set. Therefore, uniqueness is impossible.
If you really want a unique identifier for string
, use the string
itself.
这篇关于C#中如何转换字符串中的唯一ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!