Here is another version with the cryptographic functions :
include \masm32\include\masm32rt.inc
include \masm32\include\advapi32.inc
includelib \masm32\lib\advapi32.lib
RandomBytes PROTO :DWORD,:DWORD
.data
.data?
buffer db 64 dup(?)
.code
start:
call main
invoke StdOut,ADDR buffer
invoke ExitProcess,0
main PROC uses esi edi ebx
invoke RandomBytes,64,ADDR buffer
mov esi,OFFSET buffer
mov edi,26
mov ebx,64
@@:
movzx eax,BYTE PTR [esi]
xor edx,edx
div edi
and eax,1
shl eax,5
lea edx,[edx+eax+65]
mov BYTE PTR [esi],dl
add esi,1
sub ebx,1
jnz @b
ret
main ENDP
RandomBytes PROC dwLength:DWORD,pBuffer:DWORD
LOCAL hProvider:HANDLE
invoke CryptAcquireContext,ADDR hProvider,0,0,\
PROV_RSA_FULL,CRYPT_VERIFYCONTEXT or CRYPT_SILENT
invoke CryptGenRandom,hProvider,dwLength,pBuffer
invoke CryptReleaseContext,hProvider,0
ret
RandomBytes ENDP
END start