HEX string generating - extreme fast
Posted: Mon Apr 18, 2016 9:28 pm
For the latest string encryption inside QAES the PB Hex generating was absolutely to slow.
I have maked this little routine for very quick generating big HEX strings.
Test it, it is very quick and works with Ascii and Unicode
Werner Albus - http://www.quick-aes-256.de - http://www.nachtoptik.de
I have maked this little routine for very quick generating big HEX strings.
Test it, it is very quick and works with Ascii and Unicode
Werner Albus - http://www.quick-aes-256.de - http://www.nachtoptik.de
Code: Select all
*buffer=AllocateMemory(1e6) ; Buffer to encoding
len_string_bytes=MemorySize(*buffer)
RandomData(*buffer, len_string_bytes)
Repeat
string_1$+RSet(Hex(i), 2, "0")
i+1
Until i=256
time=ElapsedMilliseconds()
string$=Space(len_string_bytes*2)
len_string_bytes-1
If SizeOf(character)>1
Repeat
PokeL(@string$+iii, PeekL(@string_1$+PeekA(*buffer+iiii)*4))
iiii+1 : iii+4
Until iiii>len_string_bytes
Else
Repeat
PokeW(@string$+iii, PeekW(@string_1$+PeekA(*buffer+iiii)*2))
iiii+1 : iii+2
Until iiii>len_string_bytes
EndIf
Debug (ElapsedMilliseconds()-time)
Debug string$
time=ElapsedMilliseconds()
string$="" : i=0 ; PB variante
Repeat
string$+RSet(Hex(PeekA(*buffer+i)), 2, "0")
i+1
Until i=len_string_bytes
Debug (ElapsedMilliseconds()-time)