|
-
Mar 6th, 2004, 06:39 AM
#1
Thread Starter
Supreme User
Simple way to encrypt URL's
VB Code:
Private Function Encrypt(strInput As String) As String
Dim letters As String
Dim encArr() As Variant
Dim daChar As String
Dim strOutput As String
letters = "abcdefghijklmnopqrstuvwxyz/.1234567890~_:"
encArr = Array("%61", "%62", "c", "%64", "e", "%66", "%67", "%68", "%69", _
"%6a", "%6b", "%6c", "m", "n", "o", "%70", "%71", "%72", "%73", "t", "%75", _
"%76", "w", "%78", "%79", "%7a", "/", ".", "1", "2", "3", "4", "5", "6", "7", _
"8", "9", "0", "~", "_", "!", ":")
For i = 1 To Len(strInput)
daChar = Mid(strInput, i, 1)
For e = 1 To Len(letters)
If daChar = Mid(letters, e, 1) Then
strOutput = strOutput & encArr(e - 1)
Exit For
End If
Next
Next
Encrypt = strOutput
End Function
Private Sub cmdEncrypt_Click()
txtEncryptedURL.Text = Encrypt(txtURL.Text)
End Sub
-
Apr 23rd, 2005, 07:57 PM
#2
Re: Simple way to encrypt URL's
What does that do?
-
Apr 24th, 2005, 07:31 AM
#3
Thread Starter
Supreme User
Re: Simple way to encrypt URL's
it encodes the text
I had this in delphi too, cant find the bugger though
-
Apr 24th, 2005, 07:54 AM
#4
Re: Simple way to encrypt URL's
 Originally Posted by Madboy
it encodes the text 
That function partly URL encodes the text. But URL encoding is not meant for letters and numbers it was designed to encode special characters like @, =, & etc.
This isn't encryption eiether, it is encoding which is used to make data safe for transport over the Internet via a URL or HTTP request.
This function encodes a URL. Notice how it only replces characters which are are not letters or numbers:
VB Code:
' url encodes a string
Function URLEncode(ByVal str As String) As String
Dim intLen As Integer
Dim X As Integer
Dim curChar As Long
Dim newStr As String
intLen = Len(str)
newStr = ""
' encode anything which is not a letter or number
For X = 1 To intLen
curChar = Asc(Mid$(str, X, 1))
If curChar = 32 Then
' we can use a + sign for a space
newStr = newStr & "+"
ElseIf (curChar < 48 Or curChar > 57) And _
(curChar < 65 Or curChar > 90) And _
(curChar < 97 Or curChar > 122) Then
newStr = newStr & "%" & Hex(curChar)
Else
newStr = newStr & Chr(curChar)
End If
Next X
URLEncode = newStr
End Function
-
Apr 24th, 2005, 09:31 AM
#5
Thread Starter
Supreme User
Re: Simple way to encrypt URL's
And the Delphi.......please?
-
Apr 24th, 2005, 09:42 AM
#6
Re: Simple way to encrypt URL's
 Originally Posted by Madboy
And the Delphi.......please? 
What delphi?
-
May 20th, 2005, 07:07 PM
#7
Thread Starter
Supreme User
Re: Simple way to encrypt URL's
Whats the delphi code equivelant?
-
Jun 4th, 2005, 01:09 PM
#8
Thread Starter
Supreme User
Re: Simple way to encrypt URL's
Would you please help me to convert this Visual Basic code from above, so i may use it in a Delphi application?
Thanks
-
Jun 4th, 2005, 02:31 PM
#9
Re: Simple way to encrypt URL's
Remember, strings are arrays in Delphi. Use the Length function to determine the length of the string. Use its index to extract a single character you address the string like you would an array. You can use the ord function to get the ascii value of a character.
-
Jun 4th, 2005, 05:19 PM
#10
Thread Starter
Supreme User
Re: Simple way to encrypt URL's
-
Jun 27th, 2005, 05:04 AM
#11
Thread Starter
Supreme User
Re: Simple way to encrypt URL's
still no joy, care to help a hand?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|