Created
August 27, 2016 18:14
-
-
Save aboisvert/52b967242cfcea3defbbbe35b741151a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strutils | |
const SHA512Len = 64 | |
proc SHA512(d: cstring, n: culong, md: cstring = nil): cstring {.cdecl, dynlib: "libssl.dylib", importc.} | |
proc SHA512(s: string): string = | |
result = "" | |
let s = SHA512(s.cstring, s.len.culong) | |
for i in 0 .. < SHA512Len: | |
result.add s[i].BiggestInt.toHex(2).toLowerAscii | |
echo SHA512("Rosetta code") |
Author
aboisvert
commented
Aug 27, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment