Available
amalgame-random
PCG-32 + crypto-grade entropy.
Overview
Two sources. new Random(seed): PCG-32, same seed, same sequence, for simulations and tests. Random.SystemBytes(n): bytes from the OS (getentropy or /dev/urandom on Unix, BCryptGenRandom on Windows), for keys and tokens.
Features
- ✓
new Random(seed): PCG-32, deterministic - ✓
Random.SystemBytes(n): OS entropy for secrets/IDs - ✓
NextInt,NextUInt32,IntRange(min, max),Float,Bool,Bytes(n) - ✓
Random.FromSystem(): a PCG-32 generator with an unguessable seed - ✓No dependency beyond libc (and bcrypt on Windows)
Example
Minimal usage example — copy-paste runnable after install.
amc package add random
import Amalgame.Random
class Program {
public static void Main() {
let r = new Random(42) // same seed, same sequence
for i in 0..5 {
Console.WriteLine(String_FromInt(r.IntRange(1, 7))) // die roll: 1 to 6
}
let key: List<int> = Random.SystemBytes(32) // 256 bits from the OS
Console.WriteLine(String_FromInt(key.Count()) + " bytes")
}
}
At a glance
- License: Apache-2.0
- Install:
amc package add random - Source: amalgame-lang/amalgame-random
- Official index: amalgame-lang/packages-index