Is Query String a unique string generator?

As soon as I asked : how is the seemingly arbitrary request / URL string created.

It can be found in many places:

http://www.youtube.com/watch?v=IMl7pvaWzh8 ^ | +---------------- http://jsfiddle.net/xeolabs/LSTKM/light/ ^ | +---------------- http://jsbin.com/asapay/1/edit ^ | +---------------- 

I was told (and it seems logical) that when the server selects a new URL, it does not check if it is free (was not previously selected)

Also, I was told that this could be the result of a formula such as: f(n+1) = f(n)+1 (therefore it is not random at all.

therefore, a new url parameter is generated as a result of the last generated url parameter.

my question is:

Where can I find such generator functions?

Of course, I can build one of my own 17 = 16 + 1, but I'm watching something ready, for example:

f(n+1) = f(n)+1 , where there are designations of uppercase, lowercase, numbers. and
Of course, minimal collisions and zero predictions.

you know something professional ...

I'm just wondering how google / youtube / jsbin / jsfiddle does this with millions of requests per day.

+7
source share
5 answers

Thinking out loud, but you can just predict a huge list of unique hashes and assign them to any new inputs. A preliminary calculation ensures that you can continue to check for conflicts, as this is not required in real time. You can look at the generation of random hashes in this question .

+2
source

This may not be the exact answer to your specific question, but if you need a function that returns a unique and unpredictable string, then there is one:

 Guid.NewGuid().ToString() 

I often use it to form unique requests in various scenarios.

0
source

System.IO has a random file name generator, maybe you can capture it.

 string randomString = System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetRandomFileName()); 

returns somthing like "jdvpmpre"

you could join a couple together to make it more unique, but that would be a quick, easy solution.

0
source

One solution (which I used myself) may be as follows:

Requirement: a unique source for increasing a sequential number (for example, a sequence in Oracle or an automatic increment index in SQL Server, etc.) is all that you can reliably process to create such an incremental source.

The workflow for generating each new URL (or whatever you need): 1 - Get the next value of your sequence. 2 - Convert it to base number 36 (you can use Google to implement it in C #, for example this one ). 3 - Use the generated base number 36 in your url (or what you do, like changing a database, etc.).

Note on base number 36: We use the decimal system in our daily operation, which consists of 10 digits. We use hexadecimal decimal numbers on computers that are made up of 16 digits (0-9 plus A, B, C, D, E and F). Now there is a 36 base system that is created using 36 digits; 0-9 and AZ, and all numbers are alphanumeric. Therefore, they can be easily used in URLs. Example from Wikipedia page: 2,821,109,907,456 decimal will be CRE66I9S in database 36.

0
source

Continuing my comment,
Assuming you have several places that accept input and generate unique tokens, I said that you can split the ranges. For example, let's say you have one site in Israel and one in the USA, and you want both to generate unique tokens (you do not want to overlap between tokens created on these sites), you can use a unique database to store the current value of the token .

(1) This is a scenario. Db starts with a token with a value of 1.
(2) An Israeli site asks db to get new tokens, db will give it a range from 1 to 1000 (not tokens, but a range). Thus, an Israeli site should not return in db for every new request it receives until it uses all these 1000 tokens.
(3) The US site is sent in dB and receives a range of 1001-2000 for tokens.
(4) In our example, you have 2 consumers and 1 manufacturer (dB). It is assumed that you want to use your db as little as possible so as not to block another consumer (s). Therefore, if each producer takes 1 second to switch to db, then how many identifiers should db give to each consumer. The answer is the number of consumers of consumer consumption / 1 second * the number of consumers. Thus, consumers have not reached an impasse, waiting for each other so that db becomes free.

So how do these manufacturers use the range? They could generate tokens with a base of 72 for the range that they received from db, increasing the counter. Why is base 72? Because it gives a short token for a large number. To come up with 72, I used az, AZ, 0-9, special characters on the keys 0-9: 25 + 25 + 10 + 10. You can rise above 72.

Implementation of session tokens is located at: https://github.com/hoytech/Session-Token

There is also this question that may be helpful:
How to create an arbitrary alphanumeric string?

0
source

All Articles