CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Encrypt

  1. #1
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Encrypt

    Anybody knows where I can find a crypting function for which is not provided the decrypt function?
    (purpouse: encrypt paswords only and match the crypted pwd with the typed in one after the last has been crypted)
    Thanks for any help
    Cesare

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Encrypt

    For every encryption, there's a decryption algorytm. It's just how good the algorytm is, that makes the encryption good. You could for instance take a fast (but easy to crack) encryption by simply XOR'ing bits over a number (like say 255, which will just swap aal the bits). This will make the password (or whatever) unreadable with the bare eye, so it should suffice for low risk applications.

    strIn = "Cimperiali"
    for t = 1 to len(strIn)
    strOut = strOut & Chr((255 Xor Asc(mid(strIn, t, 1))))
    next t
    MsgBox strOut



    This code results in something i can't even type. Of course, if you know how the encryption is done, it ain't hard to decode (in this case, simply XOR'ing it back again over 255).

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Encrypt

    http://www.freevbcode.com/ShowCode.Asp?ID=972
    ;-)
    See you, and thanks for tip.

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Encrypt

    I think you can add to each letter ASCII code a random number and then you won't be able to decrypt it.

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Encrypt

    Yes, but remember: two times submitting same word should give out same result...
    However, I think I will use something like what you suggested, after all.
    Thanks for answering, Iouri.


    'this is something I found out in the Net
    private Function EncryptString(strText as string, byval strPwd as string)
    Dim i as Integer, j as Integer
    Dim strBuff as string


    'Encrypt the string
    If len(strPwd) then
    for i = 1 to len(strText)
    j = Asc(mid$(strText, i, 1))
    j = j + Asc(mid$(strPwd, (i Mod len(strPwd)) + 1, 1))
    strBuff = strBuff & Chr$(j And &HFF)
    next i
    else
    strBuff = strText
    End If

    EncryptString = strBuff

    End Function




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  6. #6
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Encrypt

    If you want it to give the same result - means that you have encryption algorithm and it can be decrypted.
    The other solution can be to implement the decryption key. Even when the decription algorithm exists and you have the open source code, you cannot decrypt without knowing the key. For example you can encrypt by XORing with the key, which only you will know.

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  7. #7
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Encrypt

    There are plenty of examples on Planet-source-code.com.vb for Encryption.
    If you are looking for one that CAN'T be decrypted you probably need to talk to the Folks at the Pentagon or the KGB or some such outfit.
    http://www.planet-source-code.com/vb...t=Alphabetical

    John G

  8. #8
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    LoL!

    You're right. Just a pity I am already out of votes...
    Have a nice day, John G.

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  9. #9
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Encrypt

    There is only one encryption that cannot be decrypted without the key, and that involves using an encryption key that has an equal size as the text you want to encrypt. So if you want to encrypt a file of 2 megs, you will need a key of 2 megs...

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  10. #10
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Ok, Ok...

    By now I know - thanks in any case: I appreciate the hints of you all. Now do not expect me to rate you! (;-))
    See you on The Net

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  11. #11
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Ok, Ok...

    Rate? Like we do it for the rate, we just do it for the kicks. Besides, knowing you, and it being late afternoon there, you'll probably be out of votes for a couple of hours

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured