Skip to content

Instantly share code, notes, and snippets.

@nondanee
Created September 21, 2018 08:57
Show Gist options
  • Save nondanee/357264fb8e27ae2b6ecab585fef90ac5 to your computer and use it in GitHub Desktop.
Save nondanee/357264fb8e27ae2b6ecab585fef90ac5 to your computer and use it in GitHub Desktop.
ecb encrypted result
# -*- coding: utf-8 -*-
from Crypto.Cipher import AES
f = open('before.bmp','rb')
bid_header = f.read(54)
raw_data = f.read()
f.close()
pad = lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
cryptor = AES.new('use for ecb test', AES.MODE_ECB)
cipher_data = cryptor.encrypt(pad(raw_data))
f = open('after.bmp','wb')
f.write(bid_header)
f.write(cipher_data)
f.close()
@nondanee
Copy link
Author

image

@nondanee
Copy link
Author

emmm, multimedia course lecturer says .bmp use run length encoding...

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