viewtopic.php?t=37017
Well, I tried to modify it so it could output Base64 code (to help with storing encrypted text in a file)...but while I can encrypt it just fine...I can't seem to reverse it.
Here is my modified version:
Code: Select all
Procedure.s EncryptText(text.s, pw.s)
InputText.s = text
UseKey.s = pw.s
InLength = StringByteLength(text)
OutLength = InLength * 2
OutText.s = Space(OutLength)
*Buffer = @InputText
Protected i, Byte.b, KeyByte.b
Protected KeyLength = Len(Key$), KeyPos
For i = 0 To InLength-1
Byte = PeekB(*Buffer+i)
KeyByte = PeekB(@UseKey+KeyPos)
Byte ! KeyByte ! Len ! i ! KeyLength
PokeB(*Buffer+i,Byte)
KeyPos + 1
If KeyPos > KeyLength
KeyPos = 0
EndIf
Next
Base64Encoder(@InputText, InLength, @OutText, OutLength)
ProcedureReturn OutText
EndProcedure
Code: Select all
Procedure.s DecryptText(text.s, pw.s)
InputText.s = text
UseKey.s = pw.s
InLength = StringByteLength(text)
OutLength = InLingth * 0.75
OutText.s = Space(OutLength)
Base64Decoder(@InputText, InLength, @OutText, OutLength)
Length = StringByteLength(OutText)
*Buffer = @OutText
Protected i, Byte.b, KeyByte.b
Protected KeyLength = Len(Key$), KeyPos
For i = 0 To Length-1
Byte = PeekB(*Buffer+i)
KeyByte = PeekB(@UseKey+KeyPos)
Byte ! KeyByte ! Len ! i ! KeyLength
PokeB(*Buffer+i,Byte)
KeyPos + 1
If KeyPos > KeyLength
KeyPos = 0
EndIf
Next
ProcedureReturn OutText
EndProcedure
The encrypted text came out as "OxcdHBhWIhsJFh0="
however, the attempt using the second function to REVERSE it, came out with: "PAoSFD80HSMyEgoyORZNQQ=="
Could someone PLEASE help me?