Skip to content

Commit

Permalink
Use pattern guards in getSaltEncrypted.
Browse files Browse the repository at this point in the history
The use of a `do` block is unnecessary.
  • Loading branch information
jonathanknowles committed May 8, 2024
1 parent 5c55276 commit 427d830
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/crypto-primitives/src/Cryptography/Cipher/AES256CBC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@ decrypt mode key iv msg = do
WithPadding -> maybeToEither EmptyPayload (PKCS7.unpad p)

getSaltFromEncrypted :: ByteString -> Maybe ByteString
getSaltFromEncrypted msg = do
when (BS.length msg < 32) Nothing
BS.take saltLengthBytes <$> BS.stripPrefix saltPrefix msg
getSaltFromEncrypted msg
| BS.length msg < 32 = Nothing
| otherwise = BS.take saltLengthBytes <$> BS.stripPrefix saltPrefix msg

0 comments on commit 427d830

Please sign in to comment.