how to encrypt data in vb

Posted on 2001-09-10
Last Modified: 2008-02-26
Is there any fuctions in vb6 to encrypt and decrypt data or any other tips
Question by:korlakris
LVL 13

Expert Comment

ID: 6473377
there is no function build-in for you to encrypt data directly form vb, but you can program one... have a look at under visual basic section, try search for "encrypt" keyword, u will find a lot of if

Accepted Solution

glass_cookie earned 100 total points
ID: 6473426

No such function in VB, but here's some links:

Description: Use a one-time pad to encipher and decipher text (3K)

Description: Encipher text, part 2 (6K)

Description: Encipher text (3K)

and some more:

Description: This is a rather simple encryption program that will encrypt / decrypt any text file that is created by this application

View code...
Description: two separate functions for encrypting/decrypting a string/text file/whatever. Encrypts using only asc characters 1 - 26 and 255 which all show up as the same character on the screen (except a few), making it difficult to decrypt.

Description: This program encrypt or decrypt a text, with a key and a checksum checker. Very good program

That's it!

glass cookie ; )
LVL 51

Expert Comment

by:Ryan Chong
ID: 6473435
Hi korlakris,

Some resources can refer:

Task: Encryption code. It allows you to type a letter and number based password used to encrypt and decrypt the text! It uses the 64 bit cipher class module that makes it EXTREMLY difficult to hack! You can use this with a electronic journal, or with and security related programs.

and a sample from

'Encryption function
Public Function Encrypt(ByVal Plain As String)
    Dim Letter As String
    For I = 1 To Len(Plain)
        Letter = Mid$(Plain, I, 1)
        Mid$(Plain, I, 1) = Chr(Asc(Letter) + 1)
    Next I
    Encrypt = Plain
End Function
'Here's the Decryption function:
Public Function Decrypt(ByVal Encrypted As String)
Dim Letter As String
    For I = 1 To Len(Encrypted)
        Letter = Mid$(Encrypted, I, 1)
        Mid$(Encrypted, I, 1) = Chr(Asc(Letter) - 1)
    Next I
    Decrypt = Encrypted
End Function

'here is sample code to test it....
Dim strMessage As String
strMessage = "Original:"
strMessage = strMessage & "This is a test" & vbCrLf
strMessage = strMessage & vbCrLf & "Encrypted:"
strMessage = strMessage & Encrypt("This is a test") & vbCrLf
strMessage = strMessage & vbCrLf & "Un-Encrypted:"
strMessage = strMessage & Decrypt(Encrypt("This is a test"))
MsgBox strMessage

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Expert Comment

ID: 6474061
You can find some code on if you search for "Fredrik Qvarfort" too. There's a post with code for RC4, XOR, DES, Gost, TEA, Blowfish, Skipjack and Twofish. The Twofish class file contains a small bug in the Propery Let Key method though (psc won't allow me to update my code, if you want the updated code let me know).

Author Comment

ID: 6475859
thank u very much for ur valuable comments

Author Comment

ID: 6478402
Thanx for all the experts for ur valuable contribution

Author Comment

ID: 6480117
Thank very much to all the experts.


Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RUNRMTCMD from AS/400 13 101
checkbox to hide entire section 10 63
Set WorkSheet  not Working 9 52
Remove Exif Orientation before adding image to db 9 46
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 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