SHA-512

Due Friday, 10 Oct. at 1440 ET.

Setup

Requirements

  • To complete this assignment, you must:
    • Create a 42 directory in your 271rs repository.
    • This folder must be a Cargo package.
    • You may leverage other Cargo packages, provided you have written them.
      • Most likely “Macros”
      • [Read more]
      cargo new 42 --name sha512 --vcs none

My responsibility

  • I will provide a reference solution
    • It is the command line utility sha512sum which I expect you already have on your system.
    $ echo "hello world" > hi.txt
    $ sha512sum hi.txt
    db3974a97f2407b7cae1ae637c0030687a11913274d578492558e39c16c017de84eacdc8c62fe34ee4e12b4b1428817f09b6a2760c3f8a664ceae94d2434a593  hi.txt

Your responsibility

  • You will implement SHA-512 in Rust.

Test

  • Copy/paste or,
tester.sh
cargo build --release
echo "15 characters." > 15char.txt
echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." > lipsum.txt
curl https://github.com/cd-public/books/raw/main/pg1342.txt -o austen.txt 2>/dev/null
echo " === Finding errors vs. reference implementation. === "
diff <(sha512sum 15char.txt) <(./target/release/sha512 15char.txt)
diff <(sha512sum lipsum.txt) <(./target/release/sha512 lipsum.txt)
diff <(sha512sum austen.txt) <(./target/release/sha512 austen.txt)
rm 15char.txt lipsum.txt austen.txt
echo " === Errors printed. No errors denotes \"Perfect!\" === "
  • Save as tester.sh and run in the manner you run other scripts, such as via:
/bin/bash tester.sh