Skip to content

Instantly share code, notes, and snippets.

@laserlemon
Created March 24, 2011 20:59
Show Gist options
  • Select an option

  • Save laserlemon/885872 to your computer and use it in GitHub Desktop.

Select an option

Save laserlemon/885872 to your computer and use it in GitHub Desktop.
# Initialize new Triple DES, CBC cipher with PKCS5 padding
cipher = Cipher.new
# Begin
cipher.encrypt
# Pass in encryption key, as given: "...rbtrj"
cipher.key = "KEY"
# Pass in initialization vector, as given: "...gdf="
cipher.iv = "IV"
# Encrypt the timestamp alone
encrypted = cipher.update("20110323102422")
# Finish the encryption
encrypted << cipher.final
# Return the base 64 encoded result
Base64.encode64(encrypted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment