mcookie: Mmm, cookies!

No, not really. mcookie will not spit a cookie out of your CD tray. Nice thought though.


mcookie does, however, spit out a random hex string of a predetermined length — which in and of itself might not enthuse you.

But we’ve seen some script-fu in the past that has had clever and practical application, and mcookie could conceivably substitute for that.

And considering that it’s part of the venerable util-linux array, it’s 99 and 44/100 percent likely to be present in your distro by default, predictable in its behavior, and maintained by people in the know.

So let’s review: Ubiquitous, reliable, up-to-date. That has all the makings for a good program.

Want to put it to use, beyond “generating a 128-bit random hexadecimal number for use with the X authority system?” Here’s a weak little idea:

let value=$(echo 0x$(mcookie | head -c2)) && echo $value

It’s a thumbsucker, but it spits out a random decimal value converted from the first two hex digits of mcookie‘s output. Nothing earth-shattering there, but hopefully shows a little of mcookie’s versatility. Mmm, cookies. :mrgreen:

1 thought on “mcookie: Mmm, cookies!

  1. Pingback: otp: Not as simple as it looks | Inconsolation

Comments are closed.