Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

encyption and decryption

Posted on 1998-11-11
10
Medium Priority
?
210 Views
Last Modified: 2013-12-25
hai, any of you know how to do encryption and decrytion ?
please help. i want example(source code) and explainations.

any type of encryption will do (using Visual Basic).
thanks.
0
Comment
Question by:lohhian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 4

Expert Comment

by:siabod
ID: 1497567
what kind of encryption are you looking for ?
Or just any ?
0
 

Author Comment

by:lohhian
ID: 1497568
just any encryption will do (use for VB).
thanks.
0
 

Author Comment

by:lohhian
ID: 1497569
Edited text of question
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Poddy
ID: 1497570
use the CryptoAPI?
0
 
LVL 4

Accepted Solution

by:
anzen earned 30 total points
ID: 1497571
Try the following code:

' Simple XOR encryption/decription
Public Function EncDec(sDataBuff As String, sKey As String) As String
    Dim iChr As Long, sTempKey As String
    Dim nDat As Integer, nKey As Integer
    Dim sOutBuff As String

    ' First create a long enough key
    sTempKey = sKey
    While Len(sTempKey) < Len(sDataBuff)
        sTempKey = sTempKey & sKey
    Wend
   
    ' Cleanup the output buffer
    sOutBuff = vbNullString

    ' Next use the Oooold XOR method
    For iChr = 1 To Len(sDataBuff)
        nDat = Asc(Mid(sDataBuff, iChr, 1))
        nKey = Asc(Mid(sTempKey, iChr, 1))
        sOutBuff = sOutBuff & Chr(nDat Xor nKey)
    Next iChr
   
    ' Return the result (enc/dec)
    EncDec = sOutBuff            
End Function

this simple function use the old Xor trick to encode/decode a given buffer, call it the first time to encrypt and the second time to decrypt, the buffer and the key could contain any kind of char.


0
 

Author Comment

by:lohhian
ID: 1497572
anzen,

can you please leave somo more comments on it.
and what i want is encryption on one code and decryption on one code.

thanks a million. Please !!.
0
 
LVL 4

Expert Comment

by:anzen
ID: 1497573
Please explain better, what do You mean by "one code", the routine simply accepts the same code for both the operations,
if You need a "public-key" encryption method it's not that simple
and You'd better go searching for PgP on the net or getting some doc about the MS CryptoAPI !!!

My answer was for a SIMPLE encrypt/decrypt method which was what You requested !!!

0
 

Author Comment

by:lohhian
ID: 1497574
anzen, sorry for making you misunderstanding.
your code is okay, good. i like it. (i given you points :))

your example is encryption and descryption in one module, right ?

what i mean,i want is encryption in ONE MODULE and decyption in ONE MODULE.
thanks.
0
 
LVL 4

Expert Comment

by:anzen
ID: 1497575
Hmmm something like not allowing an user to encrypt (or decrypt) the data.... tell me more I'll see what to do.

P.S. You can write me directly, my mail is anzen@bolagna.crosswinds.net, let me know.
0
 

Author Comment

by:lohhian
ID: 1497576
anzen,
no ... no .. okay, let me tell you one by one.

in a form, there's a text box (to key in), one ENCRYPT command box and one DECRYPT command box.

now, when the user key into the text box, the user click on the ENCRYPT command box to encypt it.

so, know what i want ?? thanks
(can i have your email adress ?, so easy to contact you)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question