MS Access VBA Substitution Cipher Encrypt/Decrypt

vba encrypt string
vba aes encryption
excel vba encrypt cell value
openssl vba
vba encrypt file
vb6 encrypt/decrypt string
vb6 encryption algorithms
aes encryption excel

Could anyone suggest please how I can achieve a substitution cipher style; encrypt and decrypt function in VBA. I appreciate hashing is considered the better way but I need reversible encryption. Many Thanks.


You can use Blowfish. There's a Visual Basic 6 version that will work in Access, available here:

http://www.di-mgt.com.au/cryptoBlowfishVer6.html

You can also try TwoFish.

Encrypt and Decrypt data in Microsoft Access VBA, How to implement Encryption and Decryption using MS Access VBA In cryptography is a type of additive cipher here in order to encrypt and decrypt a string  Could anyone suggest please how I can achieve a substitution cipher style; encrypt and decrypt function in VBA. I appreciate hashing is considered the better way but I need reversible encryption. Many Thanks.


There is a simple example here or you can use the even simpler ROT13 cipher.

These are useful for obscuring a little text, but I'd not use them for anything that actually needs to be kept secure.

Cryptography vba, Model was used in designing and This quick and dirty encryption/decryption Represents an MS Access VBA to perform AES encryption, Base 64 encoding and create Substitute(TextCode, Chr(x), Chr(x + 5)) Next x Crypto = TextCode End  MS Access VBA to perform AES encryption, Base 64 encoding and create SHA1 hashes.


Many thanks for all the answers provided in reference to my question, it's good to see there are different approaches, this is one I coded yesterday morning. It allows a different cipher keyword/phrase to be used for both Upper & Lowercase letters, I have used 'Zebras' in this example, it also runs a second pass with the ROT13 cipher. Encryption method:

Public Function Encrypt(strvalue As String) As String

Const LowerAlpha    As String = "abcdefghijklmnopqrstuvwxyz"
Const LowerSub      As String = "zebrascdfghijklmnopqtuvwxy" 'zebras
Const UpperAlpha    As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const UpperSub      As String = "ZEBRASCDFGHIJKLMNOPQTUVWXY" 'ZEBRAS

Dim lngi            As Long
Dim lngE            As Long
Dim strEncrypt      As String
Dim strLetter       As String

If strvalue & "" = "" Then Exit Function

For lngi = 1 To Len(strvalue)

    strLetter = Mid(strvalue, lngi, 1)

    Select Case Asc(strLetter)

        Case 65 To 90 'Uppercase
            'Find position in alpha string
            For lngE = 1 To Len(UpperAlpha)
                If Mid(UpperAlpha, lngE, 1) = strLetter Then GoTo USub
            Next
USub:
            strEncrypt = strEncrypt & Mid(UpperSub, lngE, 1)

        Case 97 To 122 'Lowercase
            'Find position in alpha string
            For lngE = 1 To Len(LowerAlpha)
                If Mid(LowerAlpha, lngE, 1) = strLetter Then GoTo LSub
            Next
LSub:
            strEncrypt = strEncrypt & Mid(LowerSub, lngE, 1)

        Case Else 'Do not substitute

            strEncrypt = strEncrypt & strLetter

    End Select

Next

'Now pass this string through ROT13 for another tier of security

For lngi = 1 To Len(strEncrypt)
    Encrypt = Encrypt & Chr(Asc(Mid(strEncrypt, lngi, 1)) + 13)
Next

End Function

And this is the Decryption that goes with it:

Public Function Decrypt(strvalue As String) As String

Const LowerAlpha    As String = "abcdefghijklmnopqrstuvwxyz"
Const LowerSub      As String = "zebrascdfghijklmnopqtuvwxy" 'zebras
Const UpperAlpha    As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const UpperSub      As String = "ZEBRASCDFGHIJKLMNOPQTUVWXY" 'ZEBRAS

Dim lngi            As Long
Dim lngE            As Long
Dim strDecrypt      As String
Dim strLetter       As String

If strvalue & "" = "" Then Exit Function

'Reverse the ROT13 cipher

For lngi = 1 To Len(strvalue)
    strDecrypt = strDecrypt & Chr(Asc(Mid(strvalue, lngi, 1)) - 13)
Next

'Now reverse the encryption

For lngi = 1 To Len(strDecrypt)

    strLetter = Mid(strDecrypt, lngi, 1)

    Select Case Asc(strLetter)

        Case 65 To 90 'Uppercase
            'Find position in sub string
            For lngE = 1 To Len(UpperSub)
                If Mid(UpperSub, lngE, 1) = strLetter Then GoTo USub
            Next
USub:
            Decrypt = Decrypt & Mid(UpperAlpha, lngE, 1)

        Case 97 To 122 'Lowercase
            'Find position in sub string
            For lngE = 1 To Len(LowerSub)
                If Mid(LowerSub, lngE, 1) = strLetter Then GoTo LSub
            Next
LSub:
            Decrypt = Decrypt & Mid(LowerAlpha, lngE, 1)

        Case Else 'Do not substitute

            Decrypt = Decrypt & strLetter

    End Select

Next

End Function

I hope the coding is very simple to follow for those who do not have vast experience with VBA coding and it can be lifted straight from the page; but again thanks for all the other answers.

MS Access VBA Replacement Encryption Encryption / Decryption, Thank you very much for all the answers provided in connection with my question​, it's good to see that there are different approaches, this is the one that I  Example Code for Using Module: Encryption ' Example of modEncryption ' ' To use this example, create a new module and paste this code into it. ' Then run the procedure by putting the cursor in the procedure and pressing: ' F5 to run it, or ' F8 to step through it line-by-line (see the Debug menu for more options) Private Sub Example_modEncryption() ' Comments: Examples of modEncryption to


General VBA/VB6, Microsoft Access, Office/VBA, VB6 Modules royalty-free source code library a Unicode or ASCII string using XOR password encryption in VBA and VB6. The decrypt routine reads the characters from the string in pairs. The first is the encrypted character, and the second is the value that was used to encrypt it. The first is the XORed with the second to recover the original character, which is then added to the output string


VBA Tips, The VBA Replace function is excellent when you simply need to substitute one or In the example below we demonstrate a function that provides the ability to perform Encryption and decryption algorithms can seem like voodoo to most will easily prevent 99.99% of other users from having any access to sensitive data. But it should be directly portable to VBA. It is an inlined version because calling functions take a lot of overhead. One thing I did to make it more secure is to drop the first 3072 bytes of the keystream. Encryption and Decryption is done using the same function. I validated the pre-drop version against test values.


Playfair Cipher Decoder, PDF) New algorithm for encryption based on substitution cipher and A py 1 to n access addmoustmotionlistener advance java algorithm applet applet Rail Fence Cipher Program in C and C++[Encryption & Decryption] Here you will I have been looking for a VBA program that codes and decodes the Playfair cipher​. To create the encryption wrapper. Create the Simple3Des class to encapsulate the encryption and decryption methods. Add an import of the cryptography namespace to the start of the file that contains the Simple3Des class. In the Simple3Des class, add a private field to store the 3DES cryptographic service provider.