Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6318643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:39:47+00:00 2026-05-24T15:39:47+00:00

Looking for a simple text encryption/decryption VB6 code. Ideally, the solution should accept (text,

  • 0

Looking for a simple text encryption/decryption VB6 code. Ideally, the solution should accept (text, password) arguments and produce readable output (without any special characters), so it can be used anywhere without encoding issues.

There are lots of code available for .NET, but not really much I can find for legacy VB6. Only this I’ve found so far: http://www.devx.com/vb2themax/Tip/19211

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:39:49+00:00Added an answer on May 24, 2026 at 3:39 pm

    I’m using RC4 implementation like this

    Option Explicit
    
    Private Sub Command1_Click()
        Dim sSecret     As String
    
        sSecret = ToHexDump(CryptRC4("a message here", "password"))
        Debug.Print sSecret
        Debug.Print CryptRC4(FromHexDump(sSecret), "password")
    End Sub
    
    Public Function CryptRC4(sText As String, sKey As String) As String
        Dim baS(0 To 255) As Byte
        Dim baK(0 To 255) As Byte
        Dim bytSwap     As Byte
        Dim lI          As Long
        Dim lJ          As Long
        Dim lIdx        As Long
    
        For lIdx = 0 To 255
            baS(lIdx) = lIdx
            baK(lIdx) = Asc(Mid$(sKey, 1 + (lIdx Mod Len(sKey)), 1))
        Next
        For lI = 0 To 255
            lJ = (lJ + baS(lI) + baK(lI)) Mod 256
            bytSwap = baS(lI)
            baS(lI) = baS(lJ)
            baS(lJ) = bytSwap
        Next
        lI = 0
        lJ = 0
        For lIdx = 1 To Len(sText)
            lI = (lI + 1) Mod 256
            lJ = (lJ + baS(lI)) Mod 256
            bytSwap = baS(lI)
            baS(lI) = baS(lJ)
            baS(lJ) = bytSwap
            CryptRC4 = CryptRC4 & Chr$((pvCryptXor(baS((CLng(baS(lI)) + baS(lJ)) Mod 256), Asc(Mid$(sText, lIdx, 1)))))
        Next
    End Function
    
    Private Function pvCryptXor(ByVal lI As Long, ByVal lJ As Long) As Long
        If lI = lJ Then
            pvCryptXor = lJ
        Else
            pvCryptXor = lI Xor lJ
        End If
    End Function
    
    Public Function ToHexDump(sText As String) As String
        Dim lIdx            As Long
    
        For lIdx = 1 To Len(sText)
            ToHexDump = ToHexDump & Right$("0" & Hex(Asc(Mid(sText, lIdx, 1))), 2)
        Next
    End Function
    
    Public Function FromHexDump(sText As String) As String
        Dim lIdx            As Long
    
        For lIdx = 1 To Len(sText) Step 2
            FromHexDump = FromHexDump & Chr$(CLng("&H" & Mid(sText, lIdx, 2)))
        Next
    End Function
    

    Command1 outputs this:

    9ED5556B3F4DD5C90471C319402E
    a message here
    

    You might need better error handling on FromHexDump though.

    Update (2018-05-04)

    For much stronger AES 256-bit encryption (in ECB mode) and proper handling of unicode texts/passwords you can check out Simple AES 256-bit password protected encryption as implemented in mdAesEcb.bas module (~380 LOC).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any silverlight text to speech engine available now? I am looking for very simple
I'm looking for (simple) examples of problems for which JMS is a good solution,
Im looking for a simple bit of code that will let me add the
I am looking for a simple unpatented one-way encryption algorithm, preferably in c. I
I'm looking for a library that will allow me to deliver simple text events
I am looking for an simple online text editor that will load an online
I'm looking for C# code to convert an HTML document to plain text. I'm
I need a simple encryption for some text strings. I want to create coupon
I'm looking for a simple spell checker to use with an text input. My
I am looking for simple and short solution of accessing SELECT value on HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.