I am looking for a fast random string generator.
Currently I am using the md5 random feature, but I need to do it loads of times so something lighter would be usefull.
Anyone got an idea?
fast random
5 posts
You can use CryptGenRandom to generate an arbitrary sized random buffer. It'll save you the overhead of multiple calls.
System::Alloc 2000
Pop $R0
System::Call "advapi32::CryptAcquireContext(*i.r0,i0,i0,i1,i0x40)"
System::Call "advapi32::CryptGenRandom(ir0,i2000,iR0)"
System::Call "advapi32::CryptReleaseContext(ir0,i0)"
# $R0 contains 2000 random bytes
System::Free $R0
I need a random string (chars and numbers) between 10 and 20 chars long.
For some reason yours only reports the same
For some reason yours only reports the same
It just allocates a buffer. You need to read from that buffer on your own. You can read it byte by byte and convert each byte into 2 hex-chars, just like you got from md5.
System::Call "*$R0(&i1.r0)"
IntFmt $0 "%02x" $0
Ok I now got;
System::Alloc 2000
Pop $R0
System::Call "advapi32::CryptAcquireContext(*i.r0,i0,i0,i1,i0x40)"
System::Call "advapi32::CryptGenRandom(ir0,i2000,iR0)"
System::Call "advapi32::CryptReleaseContext(ir0,i0)"
System::Call "*$R0(&i1.r0)"
IntFmt $0 "%02x" $0
messagebox MB_OK $0
but it keeps returning 00, I got it working but for some reason it broke.
And how do I expand this to a for example 20 chars long output?
System::Alloc 2000
Pop $R0
System::Call "advapi32::CryptAcquireContext(*i.r0,i0,i0,i1,i0x40)"
System::Call "advapi32::CryptGenRandom(ir0,i2000,iR0)"
System::Call "advapi32::CryptReleaseContext(ir0,i0)"
System::Call "*$R0(&i1.r0)"
IntFmt $0 "%02x" $0
messagebox MB_OK $0
but it keeps returning 00, I got it working but for some reason it broke.
And how do I expand this to a for example 20 chars long output?