How to resolve the algorithm MD4 step by step in the Scala programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm MD4 step by step in the Scala programming language

Table of Contents

Problem Statement

Find the MD4 message digest of a string of octets. Use the ASCII encoded string “Rosetta Code” (without quotes). You may either call an MD4 library, or implement MD4 in your language. MD4 is an obsolete hash function that computes a 128-bit message digest that sometimes appears in obsolete protocols. RFC 1320 specifies the MD4 algorithm. RFC 6150 declares that MD4 is obsolete.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm MD4 step by step in the Scala programming language

Source code in the scala programming language

import org.bouncycastle.crypto.digests.MD4Digest

object RosettaRIPEMD160 extends App {
  val (raw, messageDigest) = ("Rosetta Code".getBytes("US-ASCII"), new MD4Digest())
  messageDigest.update(raw, 0, raw.length)
  val out = Array.fill[Byte](messageDigest.getDigestSize())(0)
  messageDigest.doFinal(out, 0)

  assert(out.map("%02x".format(_)).mkString == "a52bcfc6a0d0d300cdc5ddbfbefe478b")
  import scala.compat.Platform.currentTime
  println(s"Successfully completed without errors. [total ${currentTime - executionStart} ms]")
}


  

You may also check:How to resolve the algorithm Read a file character by character/UTF8 step by step in the Seed7 programming language
You may also check:How to resolve the algorithm Unix/ls step by step in the S-lang programming language
You may also check:How to resolve the algorithm Comments step by step in the Racket programming language
You may also check:How to resolve the algorithm Quaternion type step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the Oz programming language