How can I convert a BigInt to a Uint8List?

I come from a background of programming languages with more potent static varieties (C/C++/Java), and the int key phrase is throwing me off somewhat. I do not care about endianness, I simply wish to successfully return and fourth between them. I have been tinkering with this code for some time now, and that is what it is lately at. What am I doing fallacious?

Uint8List _serializeBigInt(BigInt bi) {
Uint8List array = Uint8List((bi.bitLength / 8).ceil());
for (int i = 0; i < array.period; i++) {
array[i] = (bi >> (i * 8)).toUnsigned(8).toInt();
go back array;

BigInt _deserializeBigInt(Uint8List array) {
BigInt bi = BigInt.0;
for (int i = 0; i < array.period; i++) BigInt.from((array[i] & 0xff));
bi = bi << 8;

go back bi;

View Reddit through ILostAChromosomeView Supply

You may also like...

WP2Social Auto Publish Powered By :