Random strings in ASP
The function createRRKey() takes an integer to define the length of the key to be generated, then returns the created key.
' Create key Dim RatingKey RatingKey = createRRKey(25) Response.Write RatingKey ' Function to create a key ' Picks between lower and higher case letters and numbers from the ASCII table to make a key Function createRRKey(key_length) Dim temp_key, temp_rnd, loop_a temp_key = "" For loop_a = 1 To key_length Randomize temp_rnd = Rnd If temp_rnd < 0.3 Then 'a-z temp_key = temp_key & Chr(Int(((122-97+1) * Rnd) + 97)) ElseIf temp_rnd > 0.3 AND temp_rnd < 0.6 Then 'A-Z temp_key = temp_key & Chr(Int(((90-65+1) * Rnd) + 65)) ElseIf temp_rnd > 0.6 Then '0-9 temp_key = temp_key & Chr(Int(((57-48+1) * Rnd) + 48)) End If Next createRRKey = temp_key End Function
Leave a Reply
Welcome to Thronic.com
Search this Site
Miscellaneous Links
Recent Articles
- Google-like search suggestion tool
- Linux Bash Color
- Resize a div layer with javascript
- Moving a div layer with javascript
- Web Galaxy » A sci-fi browser game
- Windows 7 on Asus Eee 900 PC
- IE and PHP sessions
- Wordpress 2.8.6 Spell Check Languages
- Reset MySQL Root Password
- Linux hosts file
- IdleGuard
- Column count in SQL
- String encryption in PHP
- Alphanumeric Captcha values in PHP
- Your own numeric Captcha in PHP
