Disponible
amalgame-random
PCG-32 + entropie crypto-grade.
Vue d'ensemble
Deux sources. new Random(seed) : PCG-32, même graine, même suite, pour les simulations et les tests. Random.SystemBytes(n) : des octets fournis par l'OS (getentropy ou /dev/urandom sur Unix, BCryptGenRandom sur Windows), pour les clés et les jetons.
Caractéristiques
- ✓
new Random(seed): PCG-32, déterministe - ✓
Random.SystemBytes(n): entropie OS pour secrets/IDs - ✓
NextInt,NextUInt32,IntRange(min, max),Float,Bool,Bytes(n) - ✓
Random.FromSystem(): un générateur PCG-32 à graine imprévisible - ✓Aucune dépendance hors de la libc (et de bcrypt sous Windows)
Exemple
Exemple minimal d'utilisation — recopiable tel quel après l'install.
amc package add random
import Amalgame.Random
class Program {
public static void Main() {
let r = new Random(42) // même graine, même suite
for i in 0..5 {
Console.WriteLine(String_FromInt(r.IntRange(1, 7))) // lancer de dé : 1 à 6
}
let key: List<int> = Random.SystemBytes(32) // 256 bits venus de l'OS
Console.WriteLine(String_FromInt(key.Count()) + " bytes")
}
}
En bref
- Licence : Apache-2.0
- Installation :
amc package add random - Code source : amalgame-lang/amalgame-random
- Index officiel : amalgame-lang/packages-index