เครื่องมือสร้างตัวเลขสุ่มหลอกที่ปลอดภัยแบบเข้ารหัสข้ามแพลตฟอร์มสำหรับ Delphi
ฉันต้องการตัวสร้างตัวเลขสุ่มข้ามแพลตฟอร์มที่ใช้งานง่ายซึ่งมีความน่าเชื่อถือมากกว่าตัวสร้างตัวเลขสุ่มในตัว เป็นแบบโมดูลาร์ คุณจึงสามารถใส่ชิ้นส่วนที่ต้องการได้เท่านั้น ใช้แพลตฟอร์มผู้ให้บริการแบบสุ่มที่ปลอดภัยสำหรับแต่ละแพลตฟอร์ม พร้อมด้วยอินเทอร์เฟซผู้ให้บริการทั่วไป ฉันทดสอบมันบน 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