Lab 1 - Stegnography
Lab 1 - Stegnography
Table of Contents
Overview......................................................................................................................................2
Task 1: Simple Classical Steganography Tools..............................................................................2
Task 1a: Analyse the hidden message....................................................................................................2
Task 2: Text Steganography.........................................................................................................2
Task 2a: Adding text files inside an Image using the copy command..................................................2
Task 3: Images Steganography.....................................................................................................2
Task 3a: LSB Steganography..................................................................................................................2
Task 3b: Image header..........................................................................................................................2
Task 4: Audio Steganography.......................................................................................................2
Overview
Objective of this lab is to make students get familiarise with steganographic tools.
if img.mode == 'RGB': n = 3
elif img.mode == 'RGBA':
n=4 total_pixels = array.size//n
message += "$t3g0"
b_message = ''.join([format(ord(i), "08b") for i in message])
req_pixels = len(b_message)
else:
index=0
for p in range(total_pixels): for q in
range(0, 3):
if index < req_pixels:
array[p][q] = int(bin(array[p][q])[2:9] +
b_message[index], 2)
index += 1
array=array.reshape(height, width, n)
enc_img = Image.fromarray(array.astype('uint8'), img.mode)
enc_img.save(dest)
print("Image Encoded Successfully")
total_pixels = array.size//n
def Decode(src):
if img.mode ==
'RGB': n = 3
elif img.mode == 'RGBA':
n = 4 total_pixels = array.size//n
hidden_bits = ""
for p in
range(total_pixels): for
q in range(0, 3):
hidden_bits += (bin(array[p][q])[2:][-1])
message = ""
for i in
range(len(hidden_bits)): if
message[-5:] == "$t3g0":
break
else:
message += chr(int(hidden_bits[i],
2)) if "$t3g0" in message:
print("Hidden Message:", message[:-
def Stego():
print("--Welcome to $t3g0--") print("1:
Encode") print("2: Decode")
func = input()
if func == '1':
print("Enter Source Image Path")
Cryptography
Lab 1: Steganography Lab
src = input()
print("Enter Message to Hide") message = input()
print("Enter Destination Image Path") dest = input()
print("Encoding...") Encode(src, message,
dest)
else:
print("ERROR: Invalid option chosen") Stego()
Hint:
Have you ever used Hex editors?
Find the header information of the given image file format (example JPEG).
Check the header info of given file and if info is wrong correct it and reopen.
Online hex editor link: https://hexed.it/
Replace starting hex digits with FF D8 FF E0
Task 4: Audio Steganography
The audio file Lab_1_Task4.wav file has some information in it. Can you find the information
hidden in the audio file?
Hint:
Have you tried to view an audio file in Sonic Visualiser?
Add spectrogram layer after opening the audio file in sonic visualiser.
How to create Audio Steganography?
5
BNM Institute of Technology Department of CSE