S
shapper
Hello,
Does anyone know how to create a TinyUrl from a url using c#?
Thanks,
Miguel
Does anyone know how to create a TinyUrl from a url using c#?
Thanks,
Miguel
I don't think they have a web api but it would be fairly simple to create
your own URL aliasing service.
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
shapper said:I believe in most applications I will only need a 2 characters length:
26 letters + 10 digits = 2 ^ 36 combinations = 68 719 476 736
Dylan said:My maths is generally rusty, and often wrong, but I’m not sure you’ve
got this correct. Shouldn’t it be 36^2 (rather than 2^36) and therefore
be only 1296 combinations?
Furthermore, you’d need a string of at least 7 characters to get close
to the number of combinations you suggested above, ie. 36^7 =
78,364,164,096.
shapper said:The problem is:
How to generate a random key and be sure that it is unique.
Obviously ... I was calculating nAp and instead of making n^p I made
p^n ...
That was a mistake when writing fast my post ... Shame ...I am a Math
College teacher ... lol
So I will increase the length and may drop a few more characters
there ...
Anyway, math is not really the problem.
The problem is:
How to generate a random key and be sure that it is unique.
Thanks,
Miguel
you can use a guid for that
Since URL should be unique, why not just generate a hash of the URL and use
it?
You mean from:http://www.mywebsite.com/document/show/ade59599-8686-49ab-b64d-35be39
Hash the part:
document/show/ade59599-8686-49ab-b64d-35be39
And add it tohttp://mywebsite.comto becomehttp://mywebsite.com/$HashResult$
Then I would place this HashResult on my Alias table associated to the
resource.
HashResult will be always unique?
And can I make it 4 characters length?
Because if it will be very long then I will not get a shorter url ...
Thanks,
Miguel
... I mean can I set the resulting hash to be always 4 characters
length whatever the length of the string being hashed?
Alias = "4ikjh"