Computing.Net > Forums > Programming > VB 6 ascii encryption

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB 6 ascii encryption

Reply to Message Icon

Name: Mark Long
Date: May 21, 2004 at 17:10:30 Pacific
OS: Win 98
CPU/Ram: 300/512
Comment:

I am trying to create a simple encryption utility using VB 6. The form has 2 displays so that when I open a file it is displayed normally in one list box and it's ascii equivalent in the other. I open the file (list of items) and they appear as they should but with just the first ascii value for the first letter of each item in the list. I realise that this is how Asc command deals with this situation but I require the ascii values for the entire string to be displayed.

Could someone please give me an example of the coding I should be using to complete my task. Thank you

Regards

M



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: May 21, 2004 at 17:18:32 Pacific
Reply:

You apply the Asc function to each character in the string inside a For/next loop using the Mid$ function.

StrLen = len(YourString)

For a = 1 to Strlen
AscChr = mid$(YourString, a,1)
next

Stuart


0

Response Number 2
Name: Mark Long
Date: May 21, 2004 at 17:30:02 Pacific
Reply:

I have declared the whole file content as the string "FileName" as this is what the user enters prior to opening the file to be encrypted. Bear with me as I am new to this VB.
Do I have to declare StrLen As Integer or will VB recognise StrLen as it is.

Thank you for your reply

M


0

Response Number 3
Name: StuartS
Date: May 22, 2004 at 03:20:04 Pacific
Reply:

You declare StrLen as an Integer.

You use each list of items in the file as a separate string.

Stuart



0

Response Number 4
Name: RazorXP
Date: May 28, 2004 at 11:39:41 Pacific
Reply:

we just did this in a programming class

heres dencryption -
Public Function DecryptStr(ByRef strIn As String, strPwd As String) As String
Dim strPass As String, strPass2 As String, intPass As Integer, intPass2 As Integer, intT As Integer
Dim intCountPass As Integer

For intCount = 1 To Len(strIn)
intCountPass = intCountPass + 1
If intCountPass > Len(strPwd) Then
intCountPass = 1
End If

strPass = Mid(strPwd, intCountPass, 1)
strPass2 = Mid(strIn, intCount, 1)
intPass = Asc(strPass)
intPass2 = Asc(strPass2)
intT = intPass2 - intPass
If intT < 0 Then
strIn = strIn & Chr(intT + 128)
End If
Next intCount
DecryptStr = strIn
End Function


and encryption-
Public Function EncryptStr(ByRef strIn As String, strPwd As String) As String
Dim intCountPass As Integer
Dim strPass As String, strPass2 As String, intPass As Integer, intPass2 As Integer, intT As Integer
For intCount = 1 To Len(strIn)
'assign letter of password asci value
intCountPass = intCountPass + 1
If intCountPass > Len(strPwd) Then
intCountPass = 1
End If

strPass = Mid(strPwd, intCountPass, 1)
strPass2 = Mid(strIn, intCount, 1)
intPass = Asc(strPass)
intPass2 = Asc(strPass2)
intT = intPass + intPass2
strIn = strIn & Chr(intT Mod 128)
Next intCount
EncryptStr = strIn
End Function

1.4 amd
pos mobo
2 gigs ddr
2 21inch montiors
radeon 9700 pro

and one of those rubber, keyboards that you can roll into a ball


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB 6 ascii encryption

Vb 6 Compiler Needed www.computing.net/answers/programming/vb-6-compiler-needed/1223.html

I need help about vb 6.0 www.computing.net/answers/programming/i-need-help-about-vb-60/5404.html

VB 6 Operator www.computing.net/answers/programming/vb-6-operator/521.html