def octets
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/sha512.bend as Sha512import Base
140# A base-256 representation, most significant digit first, of fixed width.
141def octets(width: Nat, +n: Nat) -> List<&2, U32>:
142 match width:
143 case 0n:
144 Nil{}
145 case 1n+p:
146 List.append(&2, U32, octets(p, Nat.div(n, 256n)),
147 [U32.from_nat(Nat.mod(n, 256n))])