DelphiCSPRNG
1.0.0
مولد أرقام عشوائية زائفة آمن ومشفر عبر الأنظمة الأساسية لدلفي
كنت أرغب في استخدام مولد أرقام عشوائي عبر الأنظمة الأساسية يكون أكثر موثوقية من مولد الأرقام العشوائي المدمج. إنها وحدات بحيث يمكنك فقط تضمين الأجزاء التي تريدها. يستفيد من النظام الأساسي المزود العشوائي الآمن لكل منصة، مع واجهة مزود مشتركة. لقد قمت باختباره فقط على Win32 وWin64 وAndroid64 وLinux64.
هناك بعض الاختبارات الأساسية ونموذج التطبيق. مفتوح للتعليقات وإصدار التقارير وطلبات السحب. خاصة إذا كنت تريد اختباره على أجهزة Apple.
إخلاء المسؤولية : تأكد من فهمك لأي كود قبل استخدامه لأي شيء مهم. فقط لأنني أسمي هذا "آمن التشفير" لا يعني بالضرورة أنه آمن أو مناسب للتشفير.
uses CSPRNG, CSPRNG.Interfaces;
// /
var rng: ICSPRNGProvider := GetCSPRNGProvider;
Writeln(rng.GetFloat);
Writeln(rng.GetUInt64);
Writeln(rng.GetBase64);
type
ICSPRNGProvider = interface
// Generates a specified number of cryptographically secure random bytes.
function GetBytes ( const Count: Integer): TBytes;
// Generates a cryptographically secure random unsigned 32-bit integer.
function GetUInt32 ( const max: UInt32 = High(UInt32)): UInt32;
// Generates a cryptographically secure random signed 32-bit integer.
function GetInt32 ( const max: Int32 = High(Int32)): Int32;
// Generates a cryptographically secure random signed 64-bit integer.
function GetInt64 ( const max: Int64 = High(Int64)): Int64;
// Generates a cryptographically secure random unsigned 64-bit integer.
function GetUInt64 ( const max: UInt64 = High(UInt64)): UInt64;
// Generates a cryptographically secure random float between 0 and 1
function GetFloat : Double;
// Generates a BASE64 encoded random string
function GetBase64 ( const len: Integer = 1024 ): String;
end ;
تأتي معظم الوظائف من التنفيذ الأساسي، حيث يوفر التنفيذ المحدد للنظام الأساسي وظيفة GetBytes
.