Cameron Hotchkies

Categories

  • Coding

Tags

  • cryptography
  • scala
  • sha-1
  • sha1

I’ve been using the Matasano crypto challenges to augment my Scala language skills. So far I’d say it’s been worth the effort. As part of the challenges, there is a requirement to find an implementation of SHA-1 in the language you’re using for the rest of the challenges, but calling the framework digest libraries was not acceptable. After spending about 3 seconds not finding an implementation in Scala, I decided to roll my own. Based on the wikipedia pseudocode I was able to do it fairly quickly.

It’s available as a gist or at the bottom of this post.

I’m not a huge fan of the code that goes from List[Byte] to Ints and back, or pretty much any of the ByteBuffer stuff, but that may just be a personal problem. I have found however that for the rest of the challenges all of the list comprehension functions have been extremely useful.