Thursday, December 13, 2007

You have a new text message (email)!

Few months ago I was having a requirement of getting notified whenever my office mail box received an email. The preferred notification-media was SMS. So basically whenever there was a new email to my official email account, I would get notified with its subject and sender via sms.

Now then, there were several obstacles I had to conquer in order to accomplish this task.

  1. Accessing & Reading my email inbox hosted at the place I work.
  2. Accessing it frequently (at least every few minutes).
  3. Hosting the program (script) that would do the above, on a server that’s available throughout the day.
  4. Protecting sensitive/personal data from third parties (in this case it was my password).
Our office uses a Microsoft Exchange Server as its mail server. Performing programmatic tasks on MS Exchange using PHP was a very rare occurrence. So I had to rely on Mr. Google in seeking a suitable code snippet that would help me in this endeavour. And guess what, I did stumble upon a blog on how to use XML-formatted WebDAV requests to fulfil my requirement.

Building on it I developed a modified version of that script, which would send an XML request to the server, read the response (it was XML too), process it, check for new mail messages, log it (because I need to keep track of what’s new & old), and sms it to my mobile. An sms was sent for each email in case of many.

I could see the inquisitive mind wondering… ;-)

A facility called ‘email2sms’ provided by my network operator was utilised in delivering the sms to my handset. This whole process was carried out every 5 minutes and the scripts that were responsible of performing this function were hosted on two web servers hosted elsewhere. That’s because my office PC is powered on during office hours only and email relaying to external destinations aren’t allowed. Moreover I don’t have permission of using the office web server for this purpose. Keep in mind that these weren’t mentioned as obstacles at the beginning of this article, as this doesn’t serve any official purpose but one of my ‘private’ needs.

Hence, I had to host the scripts on two web servers situated in different places, they both belonging to a couple of my friends (thanks guys). These servers are operational 24*7 and the every-five-minute request was handled by a simple Linux cron job.

Did you notice me mentioning 2 web servers? Wondered why? This is to overcome obstacle no. 4. In the aforesaid script there arose a need of hard-coding my email account’s password into it. This is required for the script to access my inbox since credentials need to be given. But if anyone was to open up and read the script (this wouldn’t normally happen, but my contentment of information security wouldn’t be satisfied otherwise) my password was there for his/her taking. To avoid this happening, I considered the use of cryptography.

Using the MCRYPT_CAST_256 cipher I was able to generate the encoded (cipher) text and a relevant key. The key was hosted on the server that initiates the request while the decrypt function and cipher text were on the second. The latter would perform the core activities mentioned earlier. Splitting these elements was necessary as it would make no sense to have the key, cipher text and decryption algorithm in the same place. If anyone was to try fetching the password on the second server by performing a ‘cipher text only’ attack, still they would need an extensive amount of brute-forcing to be performed. However this was evaluated by me as computationally secure for a long time.

Something worth mentioning is the disguising of the key when it’s transmitted from the first server to the second; care was taken to avoid any logging on the latter’s part so that no readable trace of it was leftover.

Although I’m not using this service these days (cos spammers occupy a decent share of my inbox ultimately filling up my sms inbox too!), the learning and application of learned theory was something to admire in solitude.

Thursday, August 02, 2007

Me the numismatist

Almost every one has some sort of hobby that keeps them accommodated during leisure time. Collecting coins is one such orthodox pastime that many people engage in. Although I used to have and maintain a ‘decent’ coin collection, time dedicated towards it has been a minimum since late.

Therefore, last week I decided to open my box of collected coins, which contains a little more than 250 coins. One thing noticeable was that I needed to do a recount and regroup of the collection, since it becomes a tedious task if a new member joins. Same as philately a properly analysed coin collection could offer you immense knowledge. After all knowledge is wealth, they say. My collection accompanies coins from more than 35 countries, spanning over 5 centuries, as I believe. Of course, there are a few unidentified pieces in it as well.

Coins of Ceylon include a few ‘VOC’ ones (now that’s not Very Old Coins) as well as ¼ and ½ cents coins too. Then there are the old British and Indian stuff as well. The filter on my collection is rather simple: foreign coins & local oldies. In addition, I have a couple of ‘token’ coins which are rather strange in the sense that they look a like tokens but seem to have been used for monetary purposes. Hmm… weird eh?

Some coins are on the verge of being ‘flattened out’ because of extensive decay. So how do I protect them or at least delay the decay? Neither am I an archaeologist nor do I have a high tech lab with protective equipment. Hence, I opted for a homemade tissue wrapping sealed with a piece of sellotape. Hopefully it would keep things in place until someone offers me some expert advice. Give it away? Where? The museum? Well, that could be considered in the future may be.

Remember me telling about the amount of information a coin collection could offer. I found it to be quite immense. From politics to botany & zoology, geography, building architecture, language, monuments, arts, history & culture, emblems, etc, the list just continues. Oh, and last but not the least hair styles too. They’re pretty old but gives us an insight towards yesteryear’s fashions.

In a way, a coin collection also teaches us a fair amount of economics. Just think of the early 1900’s 1 cent coin of Ceylon (the one with the palm tree in it) being bigger in size than the present 1 rupee! By the way, 1 rupee equals 100 cents in case you were wondering.

Coin collecting could offer you some great challenges that if won, could turn out to be pleasant surprises. I had to cross-reference details in coins with stamps or notes at times in order to figure out which country they belong to. Also, intuition, logic and a bit of common sense could be a handful in such situations.

Currently I’m thinking of a better way of storing the coins and documenting them methodically so that I could keep track and quickly refer them in the future. As an invitation, I’d like to exchange my ‘extras’ with you if interested. So till again, happy collecting!

Monday, April 02, 2007

... Loving Kindness ...

This is an effort to express the meditation of 'loving kindness' (maithree bhavana) in a poetic form :

Love to others
begin with me
well & happy
may I be

Yes, my parents
Mom and Dad
be well & happy
I'm so glad

All my siblings
brother & sis
wish you all
a mind at peace

All my friends
and my peers
be well & happy
no more tears

All you people
dear to me
and you all
not dear to me
they who think
may you all be
well & happy

Country men,
and neighbours
be well & happy
no more fears

All those beings
that we see
all those beings
we do not see
take my merits
with all glee
well & happy
may all be

Close to me or,
far from me
well & happy
may you be

North or South
East or West
Top or Bottom
wherever you rest,

Loving kindness,
Compassion we gain
eternal bliss
may you attain...