×
Namespaces

Variants
Actions

Archived:Creating SMS decoder using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

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 decrypt an SMS that has been encoded using a Rail Fence Cipher. This is the companion article to Archived:Creating SMS encoder using PySymbian, which explains how you can encode and send an SMS message.

Article Metadata
Tested with
Devices(s): N70, N95 8gb, N96
Compatibility
Platform(s): S60 2nd Edition,S60 3rd Edition FP1, S60 3rd Edition FP2
Article
Keywords: Rail Fence Cipher
Created: james1980 (30 Jan 2009)
Last edited: hamishwillee (08 May 2013)

Contents

Introduction to Rail Fence Cipher

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.

Decoding Algorithm

The code given here assume that the last message you received is the encoded one and decode that message only. Very soon i will upgrade the code to read all message in your inbox and find out which message is the encoded one.

To use this code first use read message option which will shows you encoded message and than use decode message option to read the original message(decoded one).

Algorithm use to decode SMS

  • First divide the received message in two equal parts.
  • Now from both these part read one by one character in a sequence and arrange them in a new array.
  • Join all this character and your decoded message is ready to display.

Code Snippet

import appuifw,e32
import inbox
flag=0
def exit_key_handler():
app_lock.signal()
 
def read():
global flag
flag=1
appuifw.app.title=u"Encoded Message"
box=inbox.Inbox()
id=box.sms_messages()
msg=box.content(id[0])
 
round.set(msg)
def decode():
global flag
 
if flag==0:
appuifw.note(u'First read message and than try to decode',"error")
appuifw.app.set_exit()
encoded=round.get(0,round.len())
size=round.len()
j=0
k=size/2
for i in range(k):
decodedmsg.append(encoded[j])
decodedmsg.append(encoded[k])
k+=1
j+=1
round.clear()
final=''.join(decodedmsg)
round.set(final)
 
app_lock = e32.Ao_lock()
round = appuifw.Text()
decodedmsg=[]
appuifw.app.body = round
 
appuifw.app.menu = [(u"Read message", read),(u"Decode message",decode)]
 
appuifw.app.title=u"Message Decoder"
 
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()

Screenshots

Following are some screenshots of the above script:

  • First you have to read the message:

Screenshot0095.jpg Screenshot0096.jpg

  • Next you can decode the message to get the actual message.

Screenshot0097.jpg


Related Articles

This page was last modified on 8 May 2013, at 09:00.
69 page views in the last 30 days.
×