Tiny demo to show:
Code: Select all
;; Text encryption test...
key$ = "Four score and seven years ago, and so on and so on"
a$="You can't handle the truth! Son, we live in a world that has walls. And those walls have to be guarded by men with guns."
a$+" Who's gonna do it? You? You, Lt. Weinberg? I have a greater responsibility than you can possibly fathom."
a$+" You weep for Santiago and you curse the Marines. You have that luxury. You have the luxury of Not knowing what I know:"
a$+" that Santiago's death, while tragic, probably saved lives. and my existence, while grotesque and incomprehensible"
a$+" to you, saves lives...You don't want the truth. Because deep down, in places you don't talk about at parties,"
a$+" you want me on that wall. You need me on that wall. We use words like honor, code, loyalty...we use these words"
a$+" As the backbone to a life spent defending something. You use 'em as a punchline. I have neither the time nor the inclination"
a$+" to explain myself to a man who rises and sleeps under the blanket of the very freedom I provide, then questions the manner"
a$+" in which I provide it! I'd rather you just said thank you and went on your way. Otherwise, I suggest you pick up a weapon"
a$+" and stand a post. Either way, I don't give a damn what you think you're entitled to! "
Structure Init_Vector ; I picked an init vector size = cipher blocksize
byte.a[32]
EndStructure
*initvector.Init_Vector = AllocateMemory(32)
RandomSeed(189470) ; for testing I'm using same init vector every time
For i=0 To 31
*initvector\byte[i] = Random(255)
Next
*encoded = AllocateMemory(Len(a$))
AESEncoder(@a$,*encoded,Len(a$),@key$,128,*initvector)
For i=*encoded To *encoded+MemorySize(*encoded)
charlist$+RSet(Str(PeekB(i)&$FF),3,"0")+","
Next
charlist$ = Left(charlist$,Len(charlist$)-1)
Debug "Encoded memory block contains "+Str(CountString(charlist$,"000"))+" zero bytes"
*decoded = AllocateMemory(MemorySize(*encoded))
AESDecoder(*encoded,*decoded,MemorySize(*encoded),@key$,128,*initvector)
result$ = PeekS(*decoded,MemorySize(*decoded))
MessageRequester("",result$, $80)