0% found this document useful (0 votes)
34 views2 pages

Audio Steganography

This document describes a process for hiding data in an audio file by manipulating pixel values. It takes in a data string and audio file, converts the data to binary, randomly selects pixel locations for hiding bits, embeds the bits by making pixel values even or odd, writes the new audio file, extracts the data by analyzing pixel parity, and reconstructs the original string.

Uploaded by

amna zia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Audio Steganography

This document describes a process for hiding data in an audio file by manipulating pixel values. It takes in a data string and audio file, converts the data to binary, randomly selects pixel locations for hiding bits, embeds the bits by making pixel values even or odd, writes the new audio file, extracts the data by analyzing pixel parity, and reconstructs the original string.

Uploaded by

amna zia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# -*- coding: utf-8 -*-

"""
Created on Sat Feb 15 18:17:54 2020

@author: amna
"""

import numpy as np
from random import seed

import wave

#lists define
pix=[]
stegoPix=[]
data=[]
Wave_write=[]
twoD=[]

audio =wave.open('sampleAudio.wav',mode='rb')
oneD = bytearray(list(audio.readframes(audio.getnframes())))
st = input("please enter data you want to hide: ", )
DataBitStream=''.join(format(ord(x), 'b').zfill(7) for x in st)

BitStream_arr = list(DataBitStream)
#length of data
c=len(DataBitStream)
x=input("enter the seed: ")
np.random.seed(int(x))

#random non-repeating secret key


SecretKey=np.random.permutation(c)
for x in range(0,c):
pix.append((int(oneD[SecretKey[x]])))
#hiding data
for x in range(0,c):
if (int(BitStream_arr[x]) == 1): #if data we want to hide is 1
if (pix[x] % 2 == 0):
pix[x]=pix[x]+1 #if pixel is even then made it odd

if(int(BitStream_arr[x]) == 0): #if data we want to hide is 0


if (pix[x] % 2 != 0):
pix[x]= pix[x]-1
#i
for x in range(0,c):
oneD[SecretKey[x]]=pix[x]

frame_mod = bytes(oneD)
with wave.open('song_embedded.wav', 'wb') as fd:
fd.setparams(audio.getparams())
fd.writeframes(frame_mod)
audio.close()
song= wave.open("song_embedded.wav", mode='rb')
# Convert audio to byte array
oneDstego = bytearray(list(song.readframes(song.getnframes())))

for x in range(0,c):
stegoPix.append((int(oneDstego[SecretKey[x]])))

#finding data hidden


for x in range(0,c):

#if picked pixel is even then hidden data is '0'


if(int(stegoPix[x]) % 2 == 0):
data.append(0)
#if picked pixel is odd then hidden data is '1'
if(int(stegoPix[x]) % 2 != 0):
data.append(1)
#from list to string
datastr= "".join(map(str, data))

message = ""
#from bitstream into string of character
while datastr != "":
i =chr( int(datastr[:7], 2))
message = message + i
datastr = datastr[7:]
print ("the hidden message is: ",message)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy