def octets

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/sha.bend:35

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/sha.bend as Sha
import Base

35# A base-256 representation, most significant digit first, of fixed width.
36def octets(width: Nat, +n: Nat) -> List<&2, U32>:
37  match width:
38    case 0n:
39      Nil{}
40    case 1n+p:
41      List.append(&2, U32, octets(p, Nat.div(n, 256n)),
42        [U32.from_nat(Nat.mod(n, 256n))])

Uses (7)

Used by (3)