|
-
Mar 9th, 2000, 01:02 AM
#1
Thread Starter
Member
Could someone teach me how to make an encryption program i need some source code and explain what it does im only 12 people!!!
-
Mar 9th, 2000, 01:10 AM
#2
Junior Member
Encryption is a subject a bit too long for this Forum. Heck, it covers entire books! I suggest you read a book on the subject before trying to work with it. Of course, if you just want to encrypt data NOW, then there are some libraries & modules available which would encrypt the data for you.
Raggart
-
Mar 9th, 2000, 01:17 AM
#3
Member
Here's some code, courtesy of Aaron Young. You will need two command buttons - 'open' and 'save', a multiline textbox, and a common dialog control:
Private Sub Command1_Click()
'Open Encrypted File
Dim sText As String
Dim iFile As Integer
On Error GoTo Cancelled
With CommonDialog1
.CancelError = True
.Filter = "AY Encrypted|*.aye"
.ShowOpen
iFile = FreeFile
Open .FileName For Input As iFile
sText = Input(LOF(iFile), iFile)
Close iFile
End With
If Left(sText, 12) <> "AY Encrypted" Then
MsgBox "Not an AY Encrypted File Format"
Else
Text1 = DecryptText(Mid(sText, 13))
End If
Cancelled:
End Sub
Private Sub Command2_Click()
'Save Encrypted File
On Error GoTo Cancelled
With CommonDialog1
.CancelError = True
.Filter = "AY Encrypted|*.aye"
.ShowSave
iFile = FreeFile
Open .FileName For Output As iFile
Print #iFile, EncryptText(Text1);
Close iFile
End With
MsgBox "Saved"
Cancelled:
End Sub
Function EncryptText(ByVal sText As String) As String
Dim sKey As String
Dim iKey As Integer
Dim lPos As Long
Dim iChar As Integer
Randomize Timer
sKey = Right("000" & Hex(Int(Rnd(1) * 4095)), 3)
For lPos = 1 To Len(sText)
iChar = Asc(Mid$(sText, lPos, 1))
Mid$(sText, lPos, 1) = Chr(iChar + Val("&H" & Mid(sKey, iKey + 1, 1)))
iKey = (iKey + 1) Mod 3
Next
EncryptText = "AY Encrypted" & sText & Right(Space(20) & (Val("&H" & sKey) + Len(sText)), 20)
End Function
Function DecryptText(ByVal sText As String) As String
Dim sKey As String
Dim iKey As Integer
Dim lPos As Long
Dim iChar As Integer
sKey = Right("000" & Hex(Val(Right(sText, 20)) - (Len(sText) - 20)), 3)
For lPos = 1 To Len(sText) - 20
iChar = Asc(Mid$(sText, lPos, 1))
Mid$(sText, lPos, 1) = Chr(iChar - Val("&H" & Mid(sKey, iKey + 1, 1)))
iKey = (iKey + 1) Mod 3
Next
DecryptText = Left(sText, Len(sText) - 20)
End Function
-
Mar 9th, 2000, 01:41 AM
#4
-
Mar 9th, 2000, 01:46 AM
#5
If you feel really confident, you can try using microsofts cryptoapi. But actualy it is quite complex.
For an example:
http://members.xoom.com/_XMCM/KPDTeam/api/api113.htm
-
Mar 9th, 2000, 08:03 AM
#6
Hyperactive Member
Encryption circa 1978
Hi,
Encryption has come a long way since the late 70's but, here's a scheme that was used to be used to encrypt password files. The hexidecimal number of each character of the password was inverted.
File c:\Merry Christmas.txt
-------------------------------
We wish you a Merry Christmas.
We wish you a Merry Christmas.
We wish you a Merry Christmas.
And a Happy New Year.
-------------------------------
Code:
Sub Main()
Open "c:\Merry Christmas.txt" For Input As #1
Open "c:\samtsirhC yrreM.txt" For Output As #2
Do While Not EOF(1)
ToEncode = Hex(Asc(Input(1, 1)))
If Len(ToEncode) = 1 Then ToEncode = "0" & ToEncode
Encoded = Right(ToEncode, 1) & Left(ToEncode, 1)
Print #2, Chr("&h" & Encoded);
Loop
Close
Open "c:\samtsirhC yrreM.txt" For Input As #1
Open "c:\Merry Christmas.txt" For Output As #2
Do While Not EOF(1)
ToDecode = Hex(Asc(Input(1, 1)))
If Len(ToDecode) = 1 Then ToDecode = "0" & ToDecode
Decoded = Right(ToDecode, 1) & Left(ToDecode, 1)
Print #2, Chr("&h" & Decoded);
Loop
Close
End Sub
Al.
-
Mar 9th, 2000, 02:22 PM
#7
Conquistador
-
Mar 9th, 2000, 11:44 PM
#8
Frenzied Member
A very simple program
Here is a VERY simple encryption program for demonstration purposes. I assume that when you say you are 12, that means you don't know much about programming? If this is the case, next time you might just say you are a beginner, because I know some 12 year olds that are excellent VB-ers.
Anyway, the way this simple program works is:
It takes the ASCII value (a number that represents a character) of each character in a string and changes it by a certain amount. In this case, it adds 100 to it. Then it replaces the original character with the character represented by the new ASCII value. This gives you a nonsense string.
It's kind of like an encryption code that kids use, where A=M, B=N, C=O, D=P, etc... As long as the person on the other end knows the code, he can read what was sent.
That's what the other function, the Decryptor, does. It takes the ASCII value of each character in the input string, subtracts 100 from it, and displays the new characters.
This example is very simple and easy to decode, but may work for your assignment.
Create a new project, and strech 3 text boxes across the form (Text1, then Text2 underneath it, and Text3 underneath Text2). Then put two command buttons (Command1 and Command2) below them.
Paste the following code in the form's code window and run the project. Type some text into the first text box then click the first command button. The text will be "encrypted" and printed in the second text box. Then click the second command button, and the text from the second text box will be "decrypted" and displayed in the third text box (hopefully it matches Text1).
Code:
Option Explicit
Private Sub Command1_Click()
Text2 = Encrypt(Text1)
End Sub
Private Sub Command2_Click()
Text3 = Decrypt(Text2)
End Sub
Private Function Encrypt(sText As String) As String
Dim nCounter As Integer, _
sTempStr As String
For nCounter = 1 To Len(sText)
sTempStr = sTempStr & Chr$(Asc(Mid$(sText, nCounter, 1)) + 100)
Next nCounter
Encrypt = sTempStr
End Function
Private Function Decrypt(sText As String) As String
Dim nCounter As Integer, _
sTempStr As String
For nCounter = 1 To Len(sText)
sTempStr = sTempStr & Chr$(Asc(Mid$(sText, nCounter, 1)) - 100)
Next nCounter
Decrypt = sTempStr
End Function
-
Mar 10th, 2000, 09:59 AM
#9
Thread Starter
Member
Thanx yall. im 12, and excellent at vb but i have no experience in the feild of encryption & decryption. I have from when i started the project this code:
Private Sub text1_keypress(keyascii as Integer)
static a, b, c
if keyascii > 64 and keyascii < 121 then
a = asc(text1.text)
b = chr$(a + 10)
text2.text = b
text1.text = ""
else
keyascii = 0
beep
end if
end sub
but i have no decryption and i know this encryption method is very poor but hey.
,TheVbUser
-
Mar 12th, 2000, 01:52 PM
#10
Conquistador
am i a skilled 13 year old programmer?
anybody???
-
Mar 12th, 2000, 01:53 PM
#11
Conquistador
why isn't my signature working?
-
Mar 12th, 2000, 09:19 PM
#12
Hyperactive Member
It's because you're not THAT skilled. Maybe someday, when the programming gods decide that you are acceptable, your signature might work. Right now, though, you'll have to accept the fact. You probably have an error in your signature.
bob
-
Mar 13th, 2000, 03:10 PM
#13
Conquistador
ok then smart guy (bob baddeley)
how come it's worked before??
and how come no one else's works then?
hey???
-
Apr 17th, 2001, 10:10 PM
#14
Addicted Member
Anyone who has any suggestions for encryption leave them here please: http://forums.vb-world.net/showthrea...ght=encryption
Why does everyone think I may be dangerous?  I'm just good at computers. 
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
|