randomBytesBuf method
Implementation
Uint8List randomBytesBuf(int size) {
// Allocate a buffer to hold the random data (you can choose the size)
return using<Uint8List>((Arena arena) {
final buffer = arena<ffi.UnsignedChar>();
// Use the memory allocated to `buffer`.
randombytes_buf(buffer.cast(), size);
List<int> out = [];
for (var i = 0; i < size; i++) {
out.add(buffer[i]);
}
return Uint8List.fromList(out);
});
}