Results 1 to 14 of 14

Thread: Encryption(open this its urgent)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    55

    Post

    Could someone teach me how to make an encryption program i need some source code and explain what it does im only 12 people!!!

  2. #2
    Junior Member
    Join Date
    Mar 2000
    Posts
    29

    Post

    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

  3. #3
    Member
    Join Date
    May 1999
    Posts
    49

    Post

    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

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Post

    To encrypt you text you need to do...

    First: Convert all your text to ASCII Code
    Second: Add a prefixed ASCII Code onto the original text.
    Third: Add another random generate ASCII Code onto your text. BUT this ASCII code need to be able to regenerate in the decryption process.

    You can take a look on this topics:
    http://www.vb-world.net/forums/showt...threadid=10899

    If you need, I can send you mine encrypt/decrypt dll to you. Feel free just email to me.





    Edited by Chris on 03-09-2000 at 01:47 PM

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    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

  6. #6
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post 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.

  7. #7
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Post

    i'm only 13

    i have an ocx that i made if you want it email me

    we teenagers have to stick together

  8. #8
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post 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
    ~seaweed

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    55

    Post

    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

  10. #10
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Post

    am i a skilled 13 year old programmer?

    anybody???

  11. #11
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Post

    why isn't my signature working?

  12. #12
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    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

  13. #13
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Post

    ok then smart guy (bob baddeley)

    how come it's worked before??
    and how come no one else's works then?


    hey???

  14. #14
    Addicted Member
    Join Date
    Apr 2001
    Posts
    250
    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
  •  



Click Here to Expand Forum to Full Width