Archived:Creating SMS encoder using PySymbian
All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
This article shows how to encrypt an SMS message using a Rail Fence Cipher and then send it. This is the companion article to Archived:Creating SMS decoder using PySymbian, which explains how to decode the message.
Article Metadata
Tested with
Compatibility
Article
Contents |
Rail Fence Cipher
This is very old cipher and now a days practically it is not used anywhere but Here it is used just to show the use of cryptography with Python.
The Rail Fence Cipher involves writing messages so that alternate letters are written on separate upper and lower lines. The sequence of letters on the upper line is then followed by the sequence on the lower line, to create the final encrypted message.The security of the cipher can be improved by choosing more than two lines to encrypt your message with.
For example if you want to send the message - "Meet me urgently" than this message will be coded as shown here
M . e . . e . u . g . n . l . . e . t . m . . r . e . t . y
As shown above the message is written on the two separate line by writing alternate character on different line and than this two lines are combined to create a final encrypted message as
Me eugnletm rety
The name of this cipher is given from the way the message is written here. It is written like a fence on the rail platform hence the name of this cipher is rail fence cipher.
Now if some normal user read this SMS it cant understand anything from this message but if you read the message using a SMS decoder it will give you original message.
Caution
Using this encoded message does not guaranteed you the 100% security because if someone knows that you are using a rail fence cipher than it would be easy to decrypt the message. Anybody can break this code on a single piece of paper.
Code Snippet
import appuifw
import e32
import messaging
import contacts
from appuifw import *
def exit_key_handler():
app_lock.signal()
def send():
size=round.len()
msg=round.get(0,round.len())
k=0
flag=0
if(size%2==1):
size=size+1
flag=1
j=size/2
for i in range (j):
msga.append(msg[k])
k=k+1
if(flag==1):
if(k+1==size):
msgb.append(" ")
if(k+1<size):
msgb.append(msg[k])
else:
msgb.append(msg[k])
k=k+1
part1= ''.join(msga)
part2= ''.join(msgb)
encodedmsg=part1+part2
#print encodedmsg
old_body=app.body
db=contacts.open()
entry =db.find(query(u'Name of Receipent','text'))
L=[]
for item in entry:
L.append(item.title)
if len(L)>0:
index = appuifw.selection_list(choices=L, search_field=0)
num=entry[index].find('mobile_number')[0].value
# print num
else:
note(u'No matches','error')
app.body=old_body
messaging.sms_send(num, encodedmsg)
encodedmsg=[]
part1=[]
part2=[]
msga=[]
msgb=[]
app_lock = e32.Ao_lock()
round = appuifw.Text()
appuifw.app.body = round
appuifw.app.menu = [(u"Send", send)]
appuifw.app.title=u"New Text Message"
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()
Screenshots
- Below are some screenshots of the above script:






16 Sep
2009