At the moment im working on an encryption program, just to prove something to myself. At the moment I have a problem, when I run the program it will drop a few characters and return wrong characters, here is the encrypter code.
[code=vbnet]
Dim x As Int64
Dim y As Int64
Dim z As Int64
Dim chrpos As Int64
Dim chrcode As Int64
Dim str As String
Dim Buffstr As String
Buffstr = ""
str = TBX1.Text
For z = 0 To 10
Buffstr = ""
For x = 0 To str.Length - 1
For y = -32768 To 65535
If str.Chars(x) = ChrW(y) Then
chrcode = y
chrpos = x
End If
Next
chrcode = chrcode + ((chrpos * chrpos))
While chrcode > 65535
chrcode -= 65535
End While
While chrcode <= -32768
chrcode += 32768
End While
Buffstr = Buffstr & ChrW(chrcode)
Next
str = Buffstr
Next
tbx2.Text = str
[/code]
notes:
> tbx1 and 2 are textboxes for input/output
> the difference between the encryption and decryption code is that the decryption is the addition the square of the position of the characters and the encryption is the subraction of the sqaure of the position of the characters
>when I run the code above and encrypt 195 1's then decrypt the output it rerurns
111111111111111 111111111111111 111111111111111 111111111111111 111111111111111 111222222222222 222222222222222 222223333333333 333333333333334 444444444444444 444445555555555 555555556666666 66666666667耷77耷
the output should be 195 1's but it is as above
in advance thank you for the help
[code=vbnet]
Dim x As Int64
Dim y As Int64
Dim z As Int64
Dim chrpos As Int64
Dim chrcode As Int64
Dim str As String
Dim Buffstr As String
Buffstr = ""
str = TBX1.Text
For z = 0 To 10
Buffstr = ""
For x = 0 To str.Length - 1
For y = -32768 To 65535
If str.Chars(x) = ChrW(y) Then
chrcode = y
chrpos = x
End If
Next
chrcode = chrcode + ((chrpos * chrpos))
While chrcode > 65535
chrcode -= 65535
End While
While chrcode <= -32768
chrcode += 32768
End While
Buffstr = Buffstr & ChrW(chrcode)
Next
str = Buffstr
Next
tbx2.Text = str
[/code]
notes:
> tbx1 and 2 are textboxes for input/output
> the difference between the encryption and decryption code is that the decryption is the addition the square of the position of the characters and the encryption is the subraction of the sqaure of the position of the characters
>when I run the code above and encrypt 195 1's then decrypt the output it rerurns
111111111111111 111111111111111 111111111111111 111111111111111 111111111111111 111222222222222 222222222222222 222223333333333 333333333333334 444444444444444 444445555555555 555555556666666 66666666667耷77耷
the output should be 195 1's but it is as above
in advance thank you for the help
Comment