sln_2015_04
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2015/day/4

Compute the MD5 hashes of things.

Synopsis

Documentation

main :: IO () Source #

282749
9962624

solve :: String -> Int64 -> Maybe Int Source #

Find the smallest, positive integer that has the specified number of leading zeros in its hex representation.

adventHash Source #

Arguments

:: String

player key

-> Int

number to hash

-> ByteString 

The "advent hash" of a number is the MD5 digest of a key string and a ASCII, base-10 representation of the number.

zeros :: Int64 -> ByteString -> Bool Source #

Test that the first n digits in hex-representation of the digest are 0.

finish :: Context -> ByteString Source #

Extract the final MD5 digest from a context

envelope :: ByteString -> ByteString Source #

Pad out an input string to be suitable for breaking into blocks for MD5. This algorithm pads with a 1 and then as many 0 bytes as needed so that when the 8-byte length is added that the whole message's length is a multiple of 64-bytes.

toBlocks :: ByteString -> [Vector Word32] Source #

Break a bytestring with a length that is a multiple of 64 into blocks of 16 32-bit words loaded in little-endian order.

addState :: Context -> Context -> Context Source #

Point-wise addition of the components of a Context

addBlock Source #

Arguments

:: Context 
-> Vector Word32

message chunk, 16 elements

-> Context 

data Round Source #

Constructors

Round !Int !Word32 !Int 

doRound Source #

Arguments

:: Vector Word32

message chunk

-> Mixer

mixing function for this round

-> Context

incoming state

-> Round

rotation, magic, chunk index

-> Context