BlueIshDan
☠
- Local time
- Today, 18:17
- Joined
- May 15, 2014
- Messages
- 1,122
:banghead::banghead::banghead::banghead::banghead::banghead::banghead:
Hello I'm going back to try and repair my Encryption/Decryption form that I made almost a year ago now.
My form allows the user to describe a string to be encrypted and the length of the key they wish to encrypt it with.
The program generates a key and encrypts the string based on it.
The problem resides in the decryption process. Every character that resides at the index of the length of the key (incremented) + 1 is skipped.
Say if I describe this:
Value: BlueIshdan
key_length: 5
Generated Key: ÝÈÚS (there is a value not visible here)
Encrypted Value: 0.649321266968326 0.665 N 0.651376146788991 • 0.744343891402715 0.77 x 0.747706422018349 ¿ 0.764705882352941 0.7925 0.768348623853211 È 0.728506787330317 0.7525 q 0.731651376146789 ¸ 0.665158371040724 0.6825 U 0.667431192660551 œ 0.760180995475113 0.7875 0.763761467889908 Æ 0.735294117647059 0.76 t 0.738532110091743 » 0.653846153846154 0.67 P 0.655963302752294 — 0.719457013574661 0.7425 m 0.722477064220184 ´ 0.748868778280543 0.775 z 0.752293577981651 Á
After Decryption: BlueIhDan
Here is the decryption code:
Hello I'm going back to try and repair my Encryption/Decryption form that I made almost a year ago now.
My form allows the user to describe a string to be encrypted and the length of the key they wish to encrypt it with.
The program generates a key and encrypts the string based on it.
The problem resides in the decryption process. Every character that resides at the index of the length of the key (incremented) + 1 is skipped.
Say if I describe this:
Value: BlueIshdan
key_length: 5
Generated Key: ÝÈÚS (there is a value not visible here)
Encrypted Value: 0.649321266968326 0.665 N 0.651376146788991 • 0.744343891402715 0.77 x 0.747706422018349 ¿ 0.764705882352941 0.7925 0.768348623853211 È 0.728506787330317 0.7525 q 0.731651376146789 ¸ 0.665158371040724 0.6825 U 0.667431192660551 œ 0.760180995475113 0.7875 0.763761467889908 Æ 0.735294117647059 0.76 t 0.738532110091743 » 0.653846153846154 0.67 P 0.655963302752294 — 0.719457013574661 0.7425 m 0.722477064220184 ´ 0.748868778280543 0.775 z 0.752293577981651 Á
After Decryption: BlueIhDan
Here is the decryption code:
Code:
Private Sub btnDecrypt_Click()
Dim hiddenDecryption As String
Dim decryption As String
Dim keyAsc() As Byte
Dim keyCount As Integer
Dim keyLength As Integer
Dim dec As Integer
keyLength = Len(txtKey.Value)
keyCount = 0
keyAsc = StrConv(txtKey.Value, vbFromUnicode)
For Each node In Split(txtPlainText.Value, " ")
If keyCount = 0 Then: hiddenDecryption = hiddenDecryption & node & " "
txtPlainText = hiddenDecryption
DoEvents
Pause (0.01)
If keyCount + 1 <= keyLength Then
keyCount = keyCount + 1
Else: keyCount = 0
End If
Next
keyCount = 0
For Each node In Split(hiddenDecryption, " ")
If IsNumeric(node) Then
dec = InStr(1, node, ".")
If dec > 0 Then
If Mid(node, dec, Len(node) - dec) > 0 Then
decryption = decryption & Chr((node * (keyAsc(keyCount) * 2)) - keyAsc(keyCount))
Else: decryption = decryption & Chr(Asc(node) - keyAsc(keyCount))
End If
Else: decryption = decryption & Chr(Asc(node) - keyAsc(keyCount))
End If
ElseIf Not IsNull(node) And Not node = "" Then
'a = Asc(node) Was for debugging purposes.
decryption = decryption & Chr(Asc(node) - keyAsc(keyCount))
End If
If keyCount + 1 < keyLength Then
keyCount = keyCount + 1
Else: keyCount = 0
End If
txtPlainText.Value = decryption
DoEvents
Pause (0.01)
Next
MsgBox (decryption)
txtPlainText = decryption
End Sub