Skip to content

Commit

Permalink
Ran fomatter
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewJohnHeath committed Sep 10, 2024
1 parent 973656e commit b2f8ca2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/compiler/builtins/roc/Crypt.roc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import Bool exposing [Eq]
import List
import Num exposing [U8, U64, U128]

Sha256 := { location : U64, }
Sha256 := { location : U64 }

Digest256 := { firstHalf : U128, secondHalf : U128, } implements [Eq]
Digest256 := { firstHalf : U128, secondHalf : U128 } implements [Eq]

emptySha256 : {} -> Sha256

Expand All @@ -24,16 +24,17 @@ sha256Digest : Sha256 -> Digest256

hashSha256 : List U8 -> Digest256
hashSha256 = \bytes -> {} |> emptySha256 |> sha256AddBytes bytes |> sha256Digest
u128Bytes : U128 -> List U8

u128Bytes : U128 -> List U8
u128Bytes = \number ->
loop = \n, bytes, place ->
if place == 16 then bytes
else
if place == 16 then
bytes
else
newByte = n |> Num.bitwiseAnd 255 |> Num.toU8
loop (Num.shiftRightBy n 8) (List.prepend bytes newByte) (place + 1)
loop number [] 0

digest256ToBytes : Digest256 -> List U8
digest256ToBytes = \@Digest256{ firstHalf, secondHalf } ->
digest256ToBytes = \@Digest256 { firstHalf, secondHalf } ->
List.concat (u128Bytes firstHalf) (u128Bytes secondHalf)

0 comments on commit b2f8ca2

Please sign in to comment.