Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Creating SMS decoder using PySymbian

From 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
Platform(s): S60 2nd Edition,S60 3rd Edition FP1, S60 3rd Edition FP2
Keywords: Rail Fence Cipher
Created: james1980 (30 Jan 2009)
Last edited: hamishwillee (08 May 2013)


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
def exit_key_handler():
def read():
global flag
flag=1"Encoded Message"
def decode():
global flag
if flag==0:
appuifw.note(u'First read message and than try to decode',"error")
for i in range(k):
app_lock = e32.Ao_lock()
round = appuifw.Text()
decodedmsg=[] = round = [(u"Read message", read),(u"Decode message",decode)]"Message Decoder" = exit_key_handler


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.


Related Articles

This page was last modified on 8 May 2013, at 06:00.
50 page views in the last 30 days.