Using MS Excel or any other programing language create a spr
Using MS Excel (or any other programing language) create a spreadsheet that encrypts basic text, following the basic principles of encryption. You might need to use macros.
The final output is just to enter a word in a field and the program or application encrypts the word. Later you can enter the cypher text in another field and the spreadsheet or applications decrypts. Just use symmetric encryption.
Give instructions on how to use your spreadsheet or application.
Solution
We could write this programme with VBA.net Please follow as described below.
1.Open VBA.net platform through GUI (For shortcut press ALT+F11 key).
2.Click insert module then write the code
3.
Private Function StrToPsd(ByVal Txt As String) As Long
\'abcdefghijklmn012345
abcdefghijklmnopqrstuvw0123456
Dim xVal As Long
Dim xCh As Long
Dim xSft1 As Long
Dim xSft2 As Long
Dim I As Integer
Dim xLen As Integer
xLen = Len(Txt)
For I = 1 To xLen
xCh = Asc(Mid$(Txt, I, 1))
xVal = xVal Xor (xCh * 2 ^ xSft1)
xVal = xVal Xor (xCh * 2 ^ xSft2)
xSft1 = (xSft1 + 7) Mod 19
xSft2 = (xSft2 + 13) Mod 23
Next I
StrToPsd = xVal
End Function
Private Function Encryption(ByVal Psd As String, ByVal InTxt As String, Optional ByVal Enc As Boolean = True) As String
Dim xOffset As Long
Dim xLen As Integer
Dim I As Integer
Dim xCh As Integer
Dim xOutTxt As String
xOffset = StrToPsd(Psd)
Rnd -1
Randomize xOffset
xLen = Len(InTxt)
For I = 1 To xLen
xCh = Asc(Mid$(InTxt, I, 1))
If xCh >= 32 And xCh <= 126 Then
xCh = xCh - 32
xOffset = Int((96) * Rnd)
If Enc Then
xCh = ((xCh + xOffset) Mod 95)
Else
xCh = ((xCh - xOffset) Mod 95)
If xCh < 0 Then xCh = xCh + 95
End If
xCh = xCh + 32
xOutTxt = xOutTxt & Chr$(xCh)
End If
Next I
Encryption = xOutTxt
End Function
Sub EncryptionRange()
Dim xRg As Range
Dim xPsd As String
Dim xTxt As String
Dim xEnc As Boolean
Dim xRet As Variant
Dim xCell As Range
On Error Resume Next
xTxt = ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox(\"Select a range:\", \"Kutools for Excel\", xTxt, , , , , 8)
Set xRg = Application.Intersect(xRg, xRg.Worksheet.UsedRange)
If xRg Is Nothing Then Exit Sub
xPsd = InputBox(\"Enter password:\", \"P@ssw0rd\")
If xPsd = \"\" Then
MsgBox \"Password cannot be empty\", , \"Empty Cell\"
Exit Sub
End If
xRet = Application.InputBox(\"Type 1 to encrypt cell(s);Type 2 to decrypt cell(s)\", \"Empty Cell\", , , , , , 1)
If TypeName(xRet) = \"Boolean\" Then Exit Sub
If xRet > 0 Then
xEnc = (xRet Mod 2 = 1)
For Each xCell In xRg
If xCell.Value <> \"\" Then
xCell.Value = Encryption(xPsd, xCell.Value, xEnc)
End If
Next
End If
End Sub
4.Then press F5 key to execute the VBA, and a dialog pops out for selecting cells to encrypt.
5.Then click OK and enter password for the encrypted cells in another popped out dialog.
6.Click OK, and the selected cells are encrypted.


