Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Random _random = new Random();
- public static void main()
- {
- // Size of the key, 6
- HashSet<string> set = new HashSet<string>();
- int clashes = 0;
- for (int n=0;n < 1000000;n++)
- {
- StringBuilder builder = new StringBuilder();
- for (int i =0;i < 7;i++)
- {
- if (_random.NextDouble() > 0.5)
- {
- builder.Append((char)_random.Next(97,123));
- }
- else
- {
- builder.Append(_random.Next(0,9).ToString());
- }
- }
- if (set.Contains(builder.ToString()))
- {
- clashes++;
- Console.WriteLine("clash: (" +n+ ")" +builder.ToString());
- }
- set.Add(builder.ToString());
- _random.Next();
- //Console.Write(builder.ToString());
- }
- Console.WriteLine("Clashes: " +clashes);
- Console.ReadLine();
- }
- p = ( 0.5 * ( (0.5*1/10) + (0.5*1/26) ) )^6
- Id URL
- 1 http://google.com
- 2 ...
- ... ...
- 156 ...
- ... ...
- http://site.com/1
- http://site.com/2
- ...
- http://site.com/2W
- ...
- select dbo.FX_CONV (123456) -- returns "1f5n"
- select dbo.FX_CONV (123457) -- returns "1f5o"
- 7QDBkvCA1+B9K/U0vrQx1A
- 7QDBkvCA1+B9K/U0vrQx1A==
- 5:$Hj:Pf4RLB9%kULj
Add Comment
Please, Sign In to add comment