A simple home made encryption using Python (text to sound)

Guess you want your own encryption method and you want it to be cool unlike some mundane random text.
What if your message/secret is a encrypted into a music file which no one can understand ,except you !!!
Sounds cool ???
Lets begin ….

This encryption helps you convert text into sound . So that you can document simple messages into sound , so that any one accessing your computer thinks that it is just a random sound file and nothing important .

Following are the steps :

1. Make a template of 26 sounds , convert them to .wav format and name them A to Z

(Any normal sound editor will be able to clip and change the format)

( I suggest 10 seconds for each sound will be good enough)

2.Encryption script (to convert from text to sound)

import wave
def text2sound(text):
	'''convers the given text to sound'''
	filename=text[0]+'.wav'
	w=wave.open(filename,"rb")
	out=wave.open("out.wav","wb")
	out.setparams(w.getparams())
	for filen in text:
		infile=filen+'.wav'
		w=wave.open(infile,"rb")
		out.writeframes(w.readframes(w.getnframes()))
	out.close()
ip=raw_input("Enter the message")
text2sound(ip)

3. Just enter the message and your encrypted sound is created in out.wav

Decryption :
1. Enter the name of the input file (including .wav extension) in the following script

import wave
import filecmp
import os
files=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
def sound2text(inputfile):
	'''converts sound to text file'''
	for ink in files:
		ip=ink+'.wav'
		input1=wave.open(inputfile,"rb")
		template=wave.open(ip,"rb")
		frames=template.getnframes()
		out=wave.open("temp.wav","wb")
		
		out.setparams(template.getparams())
		out.writeframes(input1.readframes(frames))
		out.close()
		if filecmp.cmp("temp.wav",ip):
			print ink
			inoutput=wave.open("tempinput.wav","wb")
			inoutput.setparams(input1.getparams())
			inoutput.writeframes(input1.readframes(input1.getnframes()))
			input1.close()
			inoutput.close()
			inoutput=wave.open("tempinput.wav","rb")
			input1=wave.open(inputfile,"wb")
			input1.setparams(inoutput.getparams())
			input1.writeframes(inoutput.readframes(inoutput.getnframes()))
			input1.close()
inp=raw_input("Enter the file name")
sound2text(inp)

2. Your audio is decrypted
Notes : I guess this method of encryption is primitive.
The script also requires you to create 26 templates in .wav format(if you are considering only alphabets).
Encryption will be transparent if you replay the sound for sometime .
Enough said , now please try the script and express your views here 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s