Basic hashing operation

Report a typo

Edwin is a movie fanatic! He wants to create a Go program that takes as input a string with a famous password used in movies, then computes the MD5 and SHA-256 hash values of it, and finally prints it in hexadecimal notation.

Edwin isn't a Go expert, so he has only written the required code to save the input within the famousPwd variable. Your task is to help him write the additional code required to compute the hash values.

Sample Input 1:

Zion0101

Sample Output 1:

65489beeb90272c11efbbd57d84a6747
cd1c9e7e676c275d7a9201f9cd00ff85f24ae65310e07f746593fdad7df954a0
Write a program in Go
package main

import (
"crypto/md5"
"crypto/sha256"
"fmt"
)

func main() {
// DO NOT delete this code block! it takes as an input the famous movie password
var famousPwd string
fmt.Scanln(&famousPwd)

// Use the correct function to create 'new' MD5 Hash and SHA-256 Hash interfaces below:
md5Hash := md5.?
sha256Hash := sha256.?

// Call the correct method that adds the 'famousPwd' to the hash that will be calculated:
md5Hash.?([]byte(?))
sha256Hash.?([]byte(?))

// Call the method that returns the computed hash slice
// And print the hash in hexadecimal notation below:
fmt.Printf("%x\n", md5Hash.?(nil))
fmt.Printf("%x\n", sha256Hash.?(nil))
}
___

Create a free account to access the full topic