enum codingType
encode = 0
decode = 1
end enum
function CryptAlg(dString as string, dKey as string, dType as codingType, dIntense as ubyte, dCalcNum as integer) as string
dim as string dNewString = dString
if (dIntense > 254) then dIntense = 254
for y as integer = 0 to dIntense
dim as string strOutput = ""
dim as integer x = 0
for i as integer = 0 to len(dNewString)-1
if x >= len(dKey) then x = 0
dim as ubyte char = dNewString[i]
if (dType = encode) then char += dCalcNum : char -= dKey[x]
if (dType = decode) then char -= dCalcNum : char += dKey[x]
strOutput &= Chr(char)
x+=1
next
dNewString = strOutput
next
return dNewString
end function
dim as string test
test = CryptAlg("Crypt Algorithm", "testkey1234567890", encode, 110, 1234567890)
print "Encrypted text: " & test
test = CryptAlg(test, "testkey1234567890", decode, 110, 1234567890)
print "Decrypted text: " & test
sleep
Last edited by D.J.Peters on Aug 11, 2022 14:42, edited 2 times in total.
function CryptAlg(dString as string, dKey as string, dType as integer, dIntense as integer, dCalcNum as integer) as string
dim as string dNewString = dString
if (dIntense > 254) then dIntense = 254
for y as integer = 0 to dIntense
dim as string strOutput = ""
dim as integer x = 0
for i as integer = 0 to len(dNewString)-1
if x >= len(dKey) then x = 0
dim as ubyte char = dNewString[i]
if (dType = 0) then char+=dCalcNum : char-=dKey[x]
if (dType = 1) then char-=dCalcNum : char+=dKey[x]
strOutput &= Chr(char)
x+=1
next
dNewString = strOutput
next
return dNewString
end function
dim as string test = CryptAlg("Crypt Algorithm", "testkey1234567890", 0, 110, 1234567890)
print "Encrypted text: " & test
test = CryptAlg(test, "testkey1234567890", 1, 110, 1234567890)
print "Decrypted text: " & test
sleep
enum encodingType
encode = 0
decode = 1
end enum
function CryptAlg(dString as string, dKey as string, dType as encodingType, dIntense as ubyte, dCalcNum as integer) as string
dim as string dNewString = dString
if (dIntense > 254) then dIntense = 254
for y as integer = 0 to dIntense
dim as string strOutput = ""
dim as integer x = 0
for i as integer = 0 to len(dNewString)-1
if x >= len(dKey) then x = 0
dim as ubyte char = dNewString[i]
if (dType = encode) then char+=dCalcNum : char-=dKey[x]
if (dType = decode) then char-=dCalcNum : char+=dKey[x]
strOutput &= Chr(char)
x+=1
next
dNewString = strOutput
next
return dNewString
end function
dim as string test
test = CryptAlg("Crypt Algorithm", "testkey1234567890", encode, 110, 1234567890)
print "Encrypted text: " & test
test = CryptAlg(test, "testkey1234567890", decode, 110, 1234567890)
print "Decrypted text: " & test
sleep