| Posted: 09:01pm 22 Dec 2024 |
|
|
|
About: V6.00.01RC10
Hi Peter, AFAIK is there an issue with
Math aes128 decrypt ctr key$,out$,comp$,iv$ I suspect that only the IV$ part (initialisation vector) is affected. If "IV$" is commented out it works (iv_enabled=0). The longstring DEcrypt version also works!
LongString AES128 DECRYPT CTR key$, lout%(), lcomp%() ,iv$
Demo code.
' Peters aes demo program for Picomites ' modified for ascii input by twofingers@TBS Option explicit CLS Const iv_enabled = 0 ' IV on/OFF <<<<<<<<<<<<<------------------- Dim string in$="",out$="",comp$="" Dim integer i Dim key$ ="0123456789ABCDEF" 'Your "Password" Dim IV$ ="0123456789012345" 'initialisation vector 'convert the message to a string version of the message Print Input "Your message (max 224): ", in$ Inc in$,String$((16-Len(in$) Mod 16)Mod 16,0) ' encrypt the message If iv_enabled Then Math aes128 encrypt ctr key$,in$,out$,iv$ Else Math aes128 encrypt ctr key$,in$,out$',iv$ EndIf
IV$=Left$(out$,16) Print "1> "out$,Len(IV$),Len(out$)
If iv_enabled Then out$=Mid$(out$,17) Print "2> "out$,Len(IV$),Len(out$) 'decrypt the message If iv_enabled Then Math aes128 decrypt ctr key$,out$,comp$,iv$ Else Math aes128 decrypt ctr key$,out$,comp$',iv$ EndIf Print out$ Print comp$ 'check for errors If in$<>comp$ Then Print "WTF" Else Print "Okay" End Regards Michael
This is a working example using "Longstring AES ..." for decrypting:
' Peters aes demo program for Picomites ' modified for ascii input by twofingers@TBS Option explicit CLS Dim string in$="",out$="",comp$="" Dim integer i Dim key$ ="0123456789ABCDEF" 'Your "Password" Dim IV$ ="0123456789012345" 'initialisation vector Dim lout%(2048),lcomp%(2048)
'convert the message to a string version of the message Print Input "Your message (max 224): ", in$ Inc in$,String$((16-Len(in$) Mod 16)Mod 16,0) ' encrypt the message Math aes128 encrypt ctr key$,in$,out$,iv$ LongString append lout%(),out$
'decrypt the message LongString AES128 DECRYPT CTR key$, lout%(), lcomp%() ,iv$ comp$ = LGetStr$(lcomp%(), 1, Len(in$)) 'Math aes128 decrypt ctr key$,out$,comp$,iv$ Print out$ Print comp$ 'check for errors If in$<>comp$ Then Print "WTF" Else Print "Okay" End Edited 2024-12-23 07:30 by twofingers |