In the holiday of school, i tried to create an encryption code for my application and i triend to make it hard to decrypt (or can't).
This is a simple encryption code, but i think hard to decrypt it. The result will similar with base64, but it isn't.
The code only contain Xor, Or, and several math operation. I named it "Triangle Encryption" because this contain formula of triangle area.
Please correct it if my it is wrong.
And, this is a module code :
Code:
Public Function ENCRYPT(PASSWORD)
For I = 1 To Len(PASSWORD)
S1 = Asc(Mid(PASSWORD, I, 1))
S2 = S1 + Round(S1 / 2, 0) Mod 256
S3 = Round(Sqr((S1 ^ 2) + (S2 ^ 2)), 0) Mod 256
K = (S1 + S2 + S3) Mod 256
L = ((1 / 2) * S1 * S2) Mod 256
T1 = S1 Xor S3
T2 = K Xor L
T3 = S2 Xor L
T = (T1 Xor T2 Xor T3) Mod 256
M1 = S1 Or S3
M2 = K Or L
M3 = S2 Or L
M = (M1 Or (M2 * M3)) Mod 256
TOTAL = TOTAL + Chr((T + M + I ^ 2 + S1) Mod 256)
Next
ENKRIPSI1 = CRYPT1(TOTAL)
ENCRYPT = ENCRYPT + ENKRIPSI1
End Function
Private Function CRYPT1(PASS)
For a = 1 To Len(PASS)
C = Asc(Mid(PASS, a, 1))
TABLEONE = Array("A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", _
"I", "i", "J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "Q", "q", "R", "r", _
"S", "s", "T", "t", "U", "u", "V", "v", "W", "w", "X", "x", "Y", "y", "Z", "z")
HSL = C Mod UBound(TABLEONE)
ONECRYPT = ONECRYPT + TABLEONE(HSL)
Next
If Len(ONECRYPT) > 0 And Len(ONECRYPT) < 20 Then CRYPT1 = ONECRYPT + "==" Else CRYPT1 = ONECRYPT
End Function



