Skip to content

Instantly share code, notes, and snippets.

@mmcc
Last active August 31, 2022 07:20
Show Gist options
  • Save mmcc/5862775 to your computer and use it in GitHub Desktop.
Save mmcc/5862775 to your computer and use it in GitHub Desktop.
Encrypt / Decrypt MP3

Request

You can create an encrypted mp3 using Zencoder's encryption settings:

{
  "input": "s3://my-bucket/super-secret.mp3",
  "output": [
    {
      "format":"mp3",
      "url":"s3://my-bucket/super-secret-encrypted.mp3",
      "encryption_method": "aes-128",
      "encryption_key": "a5f6a7d6ef5d6a7a02a23dd35dd56a63",
      "encryption_iv": "a5f6a7d6ef5d6a7a02a23dd35dd56a63"
    }
  ]
}

Obviously you won't be able to play back the file you just created, so you'll need to decrypt locally using OpenSSL:

openssl aes-128-cbc -K a5f6a7d6ef5d6a7a02a23dd35dd56a63 -iv a5f6a7d6ef5d6a7a02a23dd35dd56a63 -d -in ./super-secret-encrypted.mp3 -out ./super-secret-decoded.mp3

Encrypted media extensions may solve the issue soon, but for now even if you could decrypt this in the browser and play it back, it wouldn't do much in terms of protection. You'd be providing everything the client needed to decrypt (key / IV) in plaintext, thus rendering the encryption itself pretty useless.

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