This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Security.Cryptography; | |
public class Program { | |
public static void Main() { | |
Console.WriteLine(GeraDigitosAleatorios(8)); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Text | |
Imports System.Security.Cryptography | |
Module VBModule | |
Sub Main() | |
Console.WriteLine(GeraDigitosAleatorios(8)) | |
End Sub | |
Function GeraDigitosAleatorios(ByVal tamanho As Integer) As String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute VB_Name = "GeraDigitosAleatorios" | |
Option Explicit | |
Private Declare Function BCryptGenRandom Lib "bcrypt.dll" (ByVal hAlgorithm As Long, ByRef pbBuffer As Long, ByVal cbBuffer As Long, ByVal dwFlags As Long) As Long | |
Const BCRYPT_USE_SYSTEM_PREFERRED_RNG = &H2 | |
Const STATUS_SUCCESS = &H0 | |
Public Function GeraDigitosAleatorios(ByVal tamanho As Integer) As String | |
Const ERRO_GERACAO_SEQUENCIA_NUMERO = vbObjectError + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses | |
Windows, SysUtils; | |
function GeraDigitosAleatorios(tamanho: Integer): String; | |
type | |
TBCryptGenRandom = function(hAlgorithm: THandle; pbBuffer: PUCHAR; | |
cbBuffer, dwFlags: ULONG): ULONG; stdcall; | |
const | |
bcryptdll = 'bcrypt.dll'; | |
STATUS_SUCCESS = $00000000; |
OlderNewer