Skip to content

Instantly share code, notes, and snippets.

@adeshmukh-quizlet
Created April 25, 2020 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeshmukh-quizlet/5215d21a5f48b9148e7c8c7d2d7912e4 to your computer and use it in GitHub Desktop.
Save adeshmukh-quizlet/5215d21a5f48b9148e7c8c7d2d7912e4 to your computer and use it in GitHub Desktop.
kscript to generate base64 of md5 values
#!/usr/bin/env kscript
import java.security.MessageDigest
import java.util.Base64
val md5 = MessageDigest.getInstance("MD5")
println(args.map { Base64.getEncoder().encodeToString(md5.digest(it.toByteArray())) }.joinToString(" "))
@adeshmukh-quizlet
Copy link
Author

adeshmukh-quizlet commented Apr 25, 2020

Prerequisite

Install kscript

brew install holgerbrandl/tap/kscript

Then save the above script in your path (e.g. ~/bin/md5b64) and make it executable.

Sample usage

$ md5b64 1
xMpCOKC5I4INzFCab3WEmw==

$ md5b64 102482168
jmCpamXlkxzjDvEeGy3Q6g==

$ md5b64 "some string"
WsdJ++7JNgf8KNZmvoXnOg==

See also: bitrev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment