Archive for the 'Miscel' Category

Mockery Of A Great Tale : Happy Potter And The Half Blood Prince Movie

Despite all the poor reviews, I decided to go to a movie theater and watch the movie myself. The author of the book on which the movie is based wrote a very clearly understandable book, and I used to wonder how can a script-writer for the movie get anything wrong.

But at the end of painful 3 hours, I was left shocked, amazed and dismayed. Did the script-writer ever care to read the original book himself, or did he just make a movie listening to an oral summary of the story from his kids? The focus of the movie and the book were two different extremes. And in the end, it made mockery of the abilities of a great man.

The book and the movie I am talking about is Harry Potter and the Half Blood Prince. If you haven’t yet watched the movie, better don’t go. Read the book again and you’ll utilize your 3 hours better.

If you cannot comprehend my anguish, I’ll try to put in words a few scenes from the movie.

Its a quite night, and Harry is back in the Burrows for the winter vacations. He is idly looking out of his window. Ginny climbs up the stairs in her night dress and walks up to Harry. They look into each other’s eye and she says ‘your shoe laces’. She sits down next and ties Harry shoe laces. She stands up and they kiss ! What a dumb thing. And at this time, she was supposed to be dating Dean.

And yeah, immediately after this scene there was an appearance of two death eaters, who after fooling around with the boy and his to-be girl friend burn down the Burrow. Now, I am not sure this happened in the book. I need to check this.

Funnily, totally out of context, at one point in the story, Dumbledore summons Harry and asks him if there is anything between him and Hermoine ! Now I am damn sure this was never written down by Rowling.

The whole movie was a romantic comedy. The book had lots of excursions of Harry and Dumbledore together. Dumbledore imparts a great deal of information to Harry so as to help him in his future quest. They plunge down the memories of the great warlock and see Riddle’s mother. They try and understand what Voldemorte values the most, which then later enabled them to take a blind shot as to what might be the horcruxes. But nothing of this sort ever happens in the movie.

There are only ever two pensive visits. The first was that of Dumbledore meeting the young Riddle in the orphanage. The second was the conversation between Horace and Riddle. That’s it! Could the script writer not have omitted a few smooches and inserted a few travels. The director should realize that its not a cheap crowd that watches Harry Potter movies. These lowly tricks are not required to lure people into the theaters. By her narrative Rowling has already ensured that almost everybody will watch all the movies however poorly it has been depicted on screen.

And yet I was ready to forgive the director, until the last scene atop the Astronomy tower. They literally made mockery of the Dumbledore.

Now this is what happens in the book :

A death mark is hovering above the Astronomy tower. Horrified by the presence of the mark, Dumbledore, though tired and drained, flies to the tower. Harry accompanies him in his invisibility cloak hidden. Malfoy comes up the stairs. At this point two spells are cast – one by Malfoy disarming Dumbledore, and another by Dumbledore petrifying Harry. And this was crucial.

Now this is what is shown in the movie:

Dumbledore requests Harry to go and hide behind. The coward Harry does so. Then Draco walks up to Dumbledore and disarms him. The warlock, who just an year ago was able to duel Voldemorte, and not only that, who after wards was ready to fight the aurors too, get disarmed by a young school going boy who hardly knows ten spells. Bullshit. After a few moments, Snape walks up to the place where Harry is hiding and gestures him to remain silent. Snape next clilmbs up to where Dumbledore was and kills him. All this time the apparently courageous Harry is hiding below. Harry can move, but he doesn’t. And afetr killing Dumbledore, all the Death Eaters raze through the castle and escape unchallenged.

Why ? Why ? Why ?

Why could they have not just copied Rowlings ending. There is a reason why Rowling has more money then the script-writer of the movie. People want to read what Rowling has written, and so why can’t the director just make what people want. Why does he have to use his brains? Damn it, if he cannot figure out what is important and what is not, could he not just simply ask Rowling to mark the passages that should be made into a movie? Who the hell did advise him to infest the movie with kisses and romance leaving out all the important stuffs.

It was so stupid watching the movie of a story I so dearly loved. It angers me. It pains me. And now I hear people who haven”t read the story talk about how crappy Rowling’s concept has been.

Had I been the author, I would have most certainly sued the director.

My suggestion – If you are a great fan of Harry Potter books, do not watch the movie. Its a crappy romantic piece of shit. If you haven’t read the book yet, better invest your 3 hours in reading the book than watching this sorry excuse for a movie. Once again the Harry Potter movie disappoints me.

Printing The Last 50 Lines Of A File

Having completed the coding of my BTP, I had to test the program. I wrote down a simple C program to do this and generate the outputs in log files in a specified folder. However, I messed it up big time. The actions included creating temporary files, catenating them and then moving them. I did it horribly wrong and ended up with lots of garbage in each log file. Only the last 50 lines of each file were the results, rest garbage.

I needed a way to retain the last 50 lines of each file and discard the rest. This is when I stumbled across the tail command. It does exactly this ! All you have to do call tail -50 <filename> for each of the files. Sweet !

A simple recursive loop, calling the tail command for each file, and yay I am done with my work. Now it is the time to analyse the results.

Lastfm Makes Radio A Subscriber Only Feature

This is the message I received from the lastfm today morning

Lastfm Radio Message

Lastfm Radio Message

I am heartbroken. I never expected such a thing to happen. I was becoming fond of their radio service. But to pay $ 3 per month to just listen to songs I have in my hard disk is just not worth it. Looks like the end of the road for me and lastfm. Its a last goodbye.

A Day That Should Not Have Been

Today was indeed one of the worst days of my 4 years stay at the Indian Institute of Technology, Kharagpur. A Sunday marred by the shocking and tragic loss of a fellow KGPian, all because of the negligent behaviour of the in-campus hospital doctors and authorities.

Students once again showed their unity by staging a protest in front of the Director’s house as soon as the news broke out. It spread like a viral, and soon enough a mob gathered at the Directors house. The destruction of property was uncalled for, and irresponsible on part of the students. Yet, it was the Directors fault not improving the already degrading standards of the B.C. Roy Hospital. The unfortunate death was only the tipping point.

This is not a first-off incidence. The hospital has been in news earlier too. The Campus Newsletter, The Scholars’ Avenue, published an article which exposed the malpractices there. The report team was suspended for almost 6 months for this. The negligence continues to this day. The whole campus could testify against the hospital.

In news earlier were reports of A.P.J. Abdul Kalam inaugurating a B.C. Roy Multi speciality Research Facility (news at KGPian), but I do not know what happened to that project.

Needless to say, the student community is enraged at the incidence. The Director had to resign immediately. An Open House meeting with the students was scheduled for later in the night. Appropriate action is what we expect from the IIT authorities. Our demand for better basic amenities is not unjustified.

You can read more in this article in The Scholar’s Avenue -

Student Dies En Route From B C Roy Hospital To Kolkata

When Will The Spammers Learn

In the morning today I was reading random blogs. I came across one which said the following

We programmers always work to make our softwares safer from the idiots out there. But unfortunately, the idiots keep getting better, and so does our software have to be updated.

This is nice. A loop wherein either species benefits from the other. But shouldn’t the same rule apply to spammers as well ? When will they learn that their methods are old and taken care of. I hardly get any spams in my gmail inbox now. The last spam that fooled my gmail and got into my inbox, and believe me it was after a long long time, was one telling me about a bank account that I apparently have inherited from some rich recently deceased personality. How do you even want me to believe that !

And then those screened by the gmail spam filter, they all look ridiculous. No one can be naive enough to get fooled by those.

But the worst ones are the chain mails. An example of one is given below :

DO YOU NEED $8,000? ? ? ? ? ?

Let Bill Nelson tell you how I have run one of these promotion letters — four times in the past year. The First time I received $7,000 in cash and around $7,800 the other three. It this letter is continued as it should be, everyone profits! Yes, and don’t worry about financing or paying money back. After the first time, you’ll see what I mean, and next time you will be more eager and glad. Now, let me give you the
complete story and details.

Please forward them and in about 30 days you will be $8,000 richer.

This letter will pay up to $8,000 because there are only four names at all times. Three moves and you are in a position to receive one dollar from each participant. This chain letter was initiated by William Neham from Nashville, Tennessee, for the purpose of investment capital. But, now this has been expanded. Your participation is one dollar to the first person or firm in the Number One position below, while omitting the name to whom you sent the dollar. Then, move the list of names up one place and place your name at the bottom. Mail a copy of this letter to 20 new prospects.

MAIL YOUR LETTERS within 48 HOURS AND DO NOT BREAK THE CHAIN. When your name reaches the Number One position, it will be your turn to collect the fees. They will be sent to you by 8,000 persons like yourself. Please DO NOT BREAK THE CHAIN BECAUSE IT REALLY WORKS!! In fact, I guarantee it, provided you do not break the chain and follow the simple rules above. Try it and see. You are investing ONLY, ONE DOLLAR, and that is all you can lose. Be sure to copy this letter completely. Don’t leave any of it out.

Send your report to Imperial Sales Company, 3096 Ivey Avenue, Knoxville, Tennessee 37914. Let us know when your fee was sent and how much you received within nine days. We have at the present time almost 100% return to the people carrying out this letter promotion. The majority received $7,800. If four names should be listed on your promotion, the one in Number One position is omitted, after you send him your one dollar. Then, put your name and address in the Number Four position.

$8,000 is capital absolutely free! Send letters only to people who have secretaries or whom you personally consider “Doers.” Look — 20 times 20 times 20 equals 8,000!!!!.

People are stupid enough to fall this fraud and immediately mail the letter to as many as they can. And then there are a few mails which tell you that an anonymous lottery had been drawn in your name, and you have been fortunate enough to win a 9 figure digit as reward. The next line says that you need to provide them your identity proof, and also your bank account details so that the money can be promptly wired to your account. People don’t detect fraud even in this ! I know people who have mailed back their bank account numbers and social security numbers and have waited hoping to get lucky. Fools !

Then there is this facebook group I came  across today. It urges everyone to join up. They intend to find your look alike, where ever in the god-damned earth he may be. They claim to be able to send you details of it within a fortnight. This is their statement -

FIND YOUR LOOK ALIKE IN THE WORLD |

Perhaps there is someone in London, Paris, New York, Tokyo or Rome that looks exactly like you!

The experiment works!! Facebook is the perfect virtual platform to discover someone who is
IDENTICAL to you!

All you need to do is invite your friends to join this group!

The experts say that each human being can have around one billion different physical variations.
Since the population of the world is approximately six billion, each one of us has at least
six look-alikes in the world

FIND YOUR LOOK ALIKE IN THE WORLD aims to help us to find our look-alikes and body doubles.

So if YOU WANT, you can invite your friends to find their look alike, too!

¤ ¤ ¤ INSTRUCTIONS ¤ ¤ ¤

1 – Join this group
2 – Invite at least 15 friends (click on “Invite others to join”)
3 – You will receive updates via private messages within three weeks

… And it’s completely FREE!

IMPORTANT !!! , invite at least 15 of your friends .

In a few days we will send you a message with more instructions.

See you soon

Please tell me you can suspect something here, that the sole purpose of the creator of this group is to have lots of people join it, and then have a platform for mass spamming. The last time I checked, the group had more than a million members !

I have always wondered, whether there really exists girls as stupid, naive, senseless as is shown in a few of the tv serials, specially the blondes. Watch Two And A Half Men, and you’ll know exactly what I mean. Alternatively, watch the blondes in the Bond movies, equally stupid.

And then I look at all these spam mails, it seem to suggest an answer. Yes ! Yes indeed, there are people of both genders foolish enough never to use the grey matter and be naive enough to fall for the most foolish and simple trick over and over again. And this is why the spammers never learn. They shall never be able to spam me, but they have countless group of fools willing to dance to their tune.

Just like the Pied Piper
Led rats through the streets
We dance like marionettes
Swaying to the symphony
Of the Spammers

I do intend to write a post on spamming some day. Just so that someone might be clever again not to fall for the stupidity.

A Logger In C

Now I am working on this fair scheduling for my B Tech Project (BTP). Already having written a 1000 lines of code, it is a great pain to debug it. More so if you do not know which function might have caused the error. I needed a logger which could log all the events. The events include entering a function, any important calculation/decision it makes, any return values, so that if my program breaks down I can exactly pinpoint the source of error simply looking at the log file generated.

I have no idea if any inbuilt logging functionality exists for C programs or not. Either way, I did not have much time to google up and learn how to use it. I decided to make my own logger, a simple one, which would serve my purpose. It hardly took me 10 minutes to get over with it.

One of the important functionalities that I wanted my logger to have is indentation. The log should be properly indented, just the same way as we indent the code. When the program control enters a new function, the logging should get indented to right, and when it leaves the function, the logging should get indented by the same amount to the left. So I defined two macros, INDENT and OUTDENT. To make them work, I defined a global variable – logIndent. The logIndent would at any given time contain the amount of space by which the log has to be indented. Obviously, I initialized it with 0. Also defined is a global variable called indentVal which is the amount of spaces with which the indentation should take place. I like the value to be 2. The two macros are

#define INDENT logIndent += indentVal
#define OUTDENT logIndent -= indentVal

int indentVal = 2;
int logIndent = 0;

I defined another macro called SPACES which would print the number of spaces to produce the required indentation.

int tempIndent;
FILE *logFile;
#define SPACES for(tempIndent = 0; tempIndent < logIndent; tempIndent++) fprintf(logFile, " ");

Obviously tempIndent is a globally declared temporary variable and logFile is the file pointer to the file where the log has to be written. I initialize the logFile pointer in the main() part of my program.

And finally coming to the logger, I created a custom printf() statement using the vprintf() command. I call my logger as LogThis(). Its declaration is as follows

void LogThis(const char *format, ...);

It is constructed as follows

void LogThis(const char *format, ...) {
  va_list args;
  va_start(args, format);
  SPACES;
  vfprintf(logFile, format, args);
  va_end(args);
}

That’s it ! To use this logger, I have to do the following in my function :

#include <stdio.h>
#include <stdarg.h>
void TestLogger() {
  int returnVal;
  float retVal;

  LogThis("<TestLogger>\n");
  INDENT;

  /**
   *  Inside the function do whatever you want to
   */

  LogThis("Returns: %d, %f\n", retrunVal, retVal)

  OUTDENT;
  LogThis("</TestLogger>\n");
}

Done ! A well indented log will be produced. This has really helped me debug the code. I do not have to gdb from the last point that worked in my program. Instead, I know which function the program control was in when it threw an error. I need to gdb from that function onwards only, thus reducing the debuging time considerably. Also, in case of errors, I can increase the debugging data for that particular function, thus eliminating the need to use gdb at all.

Output Feedback Mode

[ Sometime the LATEX does not render properly. Just refresh the page and it should do. ]

OFB Encryption

OFB Encryption

OFB Decryption

OFB Decryption

Output feedback mode is similar to CFB mode except that the quantity XORed with each plain text block is generated  independently of both the plain text and cipher text. An initialization vector s_0 is used as a seed for a sequence of data blocks s_i, and each data block s_i is derived from the encryption of the previous data block s_{i-1}. The encryption of a plain text block is derived by taking the XOR of the plain text block with the relevant data block.

It is essential for security that the initial value is chosen randomly and independently from the previous ones. This prevents almost with certainty that the same initial value s_0 is used for more than one encryption.

A transmission bit error in block c_i only affects the decryption of that block. The block recovered from c_i has bit errors precisely where c_i did. However, the output feedback mode will not recover from a lost cipher text block – all following cipher text blocks will be decrypted incorrectly.

The speed of encryption is identical to that of the block cipher. Even though the process cannot easily be parallelized, time can be saved by generating the key stream before the data is available for encryption.

The output feedback mode is implemented by the following algorithm

Algorithm:

bitStream ofbEncrypt(bitStream m, s_0)

divide m into m_0m_1...m_l

for i \gets 1 to l do

c_i \gets m_i \oplus {msb_r}{({E_K}({s_i}))}

x_i \gets {E_k}({s_i})

return c_1c_2...c_l

[ This is a part of a series of post on Modes Of Encryption. I had to scribe a lecture as a requirement of a course on the Foundations Of Cryptology at the Indian Institute Of Technology. The scribe has been broken into smaller chunks so that it is easily readable. ]

Cipher Block Chaining

[ Sometimes the LATEX does not render properly. Just refresh the page and it should do. ]

In the cipher block chaining mode, each block of plain text is XORed with the previous cipher text block before being  encrypted. This was, each cipher text block is dependent on all the plain text blocks that have been processed up to  that point. Also to make each message unique, an initialization vector must be used in the first block.

CBC Encryption

CBC Encryption

CBC Decryption

CBC Decryption

CBC mode is as secure as the underlying block cipher against standard attacks. In addition any patterns in the plain text are concealed by the XORing of the previous cipher text blocks with the plain text block. Note also that the plain text cannot be directly manipulated except by removal of blocks from the beginning or the end of the cipher text. The initialization vector should be different for any two messages encrypted with the same key and is preferably randomly chosen. It does not have to be encrypted and it can be transmitted with (or considered as the first part of)  the cipher text.

If the first block has index 1, the mathematical formula for CBC encryption is

C_i = E_K(P_i \oplus C_{i-1}), C_0 = IV
while the mathematical formula for CBC decryption is
P_i = D_K(C_i) \oplus C_{i-1}, C_0 = IV

Choosing the initial value c_0 at random prevents almost with certainty that the  same initial value c_0 is used for more than one encryption. This is important for security. Suppose for a moment that the same c_0 is used for two messages m and  m^` . Then, an eavesdropper can immediately detect whether the first l blocks of m and m^` coincide, because in this case the first l ciphertext blocks are the same.

The speed of encryption is identical to that of the block cipher, but the encryption process cannot be easily parallelized, although the decryption process can be.

In this mode, we have r = n. Encryption in the cipher-block chaining mode is implemented by the following algorithm

Algorithm:

bitStream cbcEncrypt(bitStream m)

select c_0 \in \{0, 1\}^n at random

divide m into m_1m_2...m_l

for i \gets 1 to l do

c_i \gets E_k(m_i \oplus c_{i-1})

return c_0c_1c_2..c_l

Decryption in cipher-block chaining mode is implemented by the following algorithm

Algorithm:

bitStream cbcDecrypt(bitStream c)

divide c into c_0c_1c_2...c_l

for i \gets 1 to l do

m_i \gets {E_k}^{-1}(c_i) \oplus c_{i-1}

return m_1m_2...m_l

A transmission bit error in block c_i affects the decryption of the blocks c_i and c_{i+1}. The block recovered from c_i will appear random (here we assume that even a small change in the input of a block cipher will produce a random looking output), while the plaintext recovered from c_{i+1} has bit errors precisely where c_i did. The block c_{i+2} is decrypted correctly. The cipher block chaining mode is self synchronizing, even if one or more entire blocks are lost. A lost ciphertext block results in the loss of the corresponding plaintext block and errors in the next plaintext block.

In both the electronic codebook mode and cipher block chaining mode, {E_k}^{-1} is applied for decryption. Hence, both modes are also applicable with public key encryption methods, where the computation of {E_k}^{-1} requires the recipient’s secret, while E_k can be easily computed by everyone.

[ This is a part of a series of post on Modes Of Encryption. I had to scribe a lecture as a requirement of a course on the Foundations Of Cryptology at the Indian Institute Of Technology. The scribe has been broken into smaller chunks so that it is easily readable. ]

Electronic Code Book

[ Sometimes the LATEX does not render properly. Just refresh the page and it should do. ]

The simplest of all the encryption modes is the electronic codebook mode. The message is divided into blocks and each block is encrypted separately.

ECB Encryption

ECB Encryption

ECB Decryption

ECB Decryption

ECB is as secure as the underlying block cipher. However, plaintext patterns are not concealed. Each identical block of plaintext gives an identical block of ciphertext. The plaintext can be easily manipulated by removing, repeating or interchanging blocks. As the encryption is deterministic, it is not CPA secure.

The speed of each encryption is identical to that of the block cipher. ECB allows easy parallelization to yield higher performance. Unfortunately, no processing is possible before a block is seen.

In this mode we have r = n. The ECB is implemented by the following algorithm

Algorithm:

bitStream ecbEncrypt(bitStream m)

divide m into m_1m_2...m_l

for i \gets 1 to l do

c_i = E_k(m_i)

return c_1c_2...c_l

For decryption the same algorithm can be used with the decryption function {E_k}^{-1} instead of E_k.

If we encrypt many blocks, partial information about the plain text is revealed. Therefor other modes are preferable.

[ This is a part of a series of post on Modes Of Encryption. I had to scribe a lecture as a requirement of a course on the Foundations Of Cryptology at the Indian Institute Of Technology. The scribe has been broken into smaller chunks so that it is easily readable. ]

Modes Of Encryption

[ Sometimes the LATEX does not render properly. Just refresh the page and it should do. ]

Often the length of message exceeds the block length. So, the block ciphers need some extension. Consider a block cipher of length n. We fix a key k, and denote the encryption function with this key as

E_k\colon \{0, 1\}^n \to \{0, 1\}^n

To encrypt a message m that is longer than n, the message is decomposed into blocks of fixed size  r, m = m_1m_2...m_l. The individual blocks are encrypted iteratively.

The message block size r need not equal n. In few modes of encryption, r is smaller than n.

Also if the length of message m is not an integral multiple of r, then we have to complete the last block. The last block of the message can be padded out with some bits and encrypted. After decryption, the receiver must remove the padding. Therefore he must know how many bits were padded. This can be achieved, for exmple, by storing the number of padded bits in the last byte of the last block.

[ This is a part of a series of post on Modes Of Encryption. I had to scribe a lecture as a requirement of a course on the Foundations Of Cryptology at the Indian Institute Of Technology. The scribe has been broken into smaller chunks so that it is easily readable. ]




Theme Tweaker by Unreal