Swift BigInt to [UInt8]

James

I am using swift 4 and am using this implementation of BigInt: https://github.com/attaswift/BigInt

I noticed there are no native methods to convert a BigInt or NSDecimalNumber into a [UInt8], do any of you know a good implementation of this as I have not been able to find one.

Thank you

Martin R

BigUInt has a

/// Return a `Data` value that contains the base-256 representation of this integer,
/// in network (big-endian) byte order.
public func serialize() -> Data 

method (see Data Conversion.swift), so what you can do is

let bi: BigInt = ...
let bytes = Array(BigUInt(bi).serialize())

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related