Sample : Random string values for accessing files


There are many samples on the web that will do these kinda random string values. @Unique would not create a secure sting for me as it always starts with same 3 -4 letters.

i have been using this one for some time. Am not the original author of this code but i have made some modifications to it to make it fit my app.

I use this code mainly to give people access to Documents / files based on URL that they get by email.

sample  servename/dbname.nsf/XpagesForm.xsp?accesscode=TWPkfFiK8v

Function GenerateRandomAccressCode

Dim length As Integer
Dim ch,x,y,i As Integer
Dim randomvalue As Integer

Randomize
length = 10
value = “”
For i = 1 To length
Redo:
ch = CInt(Round(2 * Rnd() + 1,0))
Select Case ch
Case 1
randomvalue = CInt(Round(25 * Rnd() + 65,0))
Case 2
randomvalue = CInt(Round(25 * Rnd() + 97,0))
Case 3
randomvalue = CInt(Round(9 * Rnd() + 48,0))
End Select
If randomvalue = 108 Or Randomvalue = 49 Or Randomvalue = 48 Or Randomvalue = 79 Then
GoTo redo
End If
value = value + Chr$(randomvalue)

Next
GenerateRandomAccressCode = value
End Function

For more complex random solutions try http://www.random.org

Advertisements

One thought on “Sample : Random string values for accessing files

  1. I dugg some of you post as I cogitated they were very useful extremely helpful kdefgbbekdac

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s