Hashing the secret formula

Report a typo

Mr. Krabs 🦀 is tired of Plankton trying to steal his Krabby Patty 🍔 formula 📜 countless times! He wants to compute the hash value of the secret_formula.txt using the SHA-512 hashing algorithm.

Mr. Krabs 🦀 has already written the required code to open the secret_formula.txt file; your task is to help him write the additional required code to compute and then print in hexadecimal notation the SHA-512 hash value of the file.

Write a program
package main

import (
"crypto/sha512"
"fmt"
"io"
"log"
"os"
)

func main() {
// DO NOT delete this code block! Mr. Krabs wrote it to open the "secret_formula.txt" file.
file, err := os.Open("secret_formula.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()

// Use the correct function to create a 'new' SHA-512 Hash interface below:
sha512Hash := sha512.?()

// Copy the data from 'secret_formula.txt' to the 'sha512Hash'
// Using the correct function from the `io` package:
if _, err := io.?(?, ?); err != nil {
log.Fatal(err)
}

// Call the method that returns the computed SHA-512 hash slice of the file:
// And print the hash in hexadecimal notation below:
fmt.Printf("%x\n", sha512Hash.?(nil))
}
___

Create a free account to access the full topic