Below is a possible solution to the challenge – Challenge 40 – Cryptography Challenge 2 – Fully Functional Caesar’s Shift Cipher
1. Make a backup of your workbook
2. Open your workbook and ALT+F11
3. Locate your Workbook name in Project Explorer Window
4. Right click on your workbook name > Insert > Module
5. Copy paste the Macro code given below
6. Save your file as .xlsm
7. Call your function as =EncryptCS(A1,$B$2)
Function EncryptCS(PText, Shift) As String Dim Ws As Worksheet Dim i As Long Dim CText As String Dim PArr, CArr Application.Volatile PArr = Split(StrConv(PText, vbUnicode), vbNullChar) ReDim CArr(UBound(PArr) - 1) For i = LBound(PArr) To UBound(PArr) - 1 If Abs(77.5 - Asc(UCase(PArr(i)))) < 13 Then If Asc(LCase(PArr(i))) + Shift > 122 Then CArr(i) = Chr(Asc(PArr(i)) + Shift - 26) Else CArr(i) = Chr(Asc(PArr(i)) + Shift) End If Else CArr(i) = PArr(i) End If Next i EncryptCS = Join(CArr, "") End Function
A workbook containing the above solution can be downloaded from Solution – Challenge 40 – Cryptography Challenge 2 – Fully Functional Caesar’s Shift Cipher.
Thanks a lot
What is the reverse UDF ? I mean how to decrypt it