-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaes+stega_demo_code.py
61 lines (32 loc) · 931 Bytes
/
aes+stega_demo_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
"""AES+Stega_demo_code.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1KxPL6PG0Bx7Ke2xk25yXi-7HOBJeiEo6
"""
pip install pycrypto
# AES
import hashlib
import math
import os
from Crypto.Cipher import AES
# steganogrphy (Image)
from PIL import Image
import numpy as np
IV_SIZE = 16 # but in real 128
KEY_SIZE = 32 # 256
SALT_SIZE = 16
# clearText is your Input or Message
clearText = b"bomb in car"
password = b"criminals"
#encryption
salt = os.urandom(SALT_SIZE)
derived = hashlib.pbkdf2_hmac('sha256',password, salt , 100000, dklen = IV_SIZE + KEY_SIZE)
iv = derived[0:IV_SIZE]
key = derived[IV_SIZE:]
encrypted = salt + AES.new(key, AES.MODE_CFB, iv ).encrypt(clearText)
print(encrypted)
"""This is just a demo
If you want Full Project Code with Report then..
#Mail me now at [email protected]
"""