Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# how to convert string in to unique ID

Tags:

.net

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?Æ

like image 437
User6996 Avatar asked Dec 02 '25 08:12

User6996


1 Answers

This is impossible without restricting your domain. There are infinitely many strings 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.

like image 162
jason Avatar answered Dec 03 '25 23:12

jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!