How to resolve the algorithm SHA-256 step by step in the Nim programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm SHA-256 step by step in the Nim programming language
Table of Contents
Problem Statement
SHA-256 is the recommended stronger alternative to SHA-1. See FIPS PUB 180-4 for implementation details. Either by using a dedicated library or implementing the algorithm in your language, show that the SHA-256 digest of the string "Rosetta code" is: 764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf
Let's start with the solution:
Step by Step solution about How to resolve the algorithm SHA-256 step by step in the Nim programming language
Source code in the nim programming language
import nimcrypto
echo sha256.digest("Rosetta code")
import strutils
const SHA256Len = 32
proc SHA256(d: cstring, n: culong, md: cstring = nil): cstring {.cdecl, dynlib: "libssl.so", importc.}
proc SHA256(s: string): string =
result = ""
let s = SHA256(s.cstring, s.len.culong)
for i in 0 ..< SHA256Len:
result.add s[i].BiggestInt.toHex(2).toLower
echo SHA256("Rosetta code")
You may also check:How to resolve the algorithm Find limit of recursion step by step in the Scala programming language
You may also check:How to resolve the algorithm URL decoding step by step in the jq programming language
You may also check:How to resolve the algorithm Retrieve and search chat history step by step in the Julia programming language
You may also check:How to resolve the algorithm 100 doors step by step in the EGL programming language
You may also check:How to resolve the algorithm Classes step by step in the Kotlin programming language