Saturday, February 28, 2015

It's a secret (11)

The Vigenère cipher reigned supreme from around the mid-16th century to the mid-19th, and for much of that time was considered unbreakable.  But then Charles Babbage in England and Friedrich Kasiski in Prussia, working independently, showed that it could be broken.  It had been known for some time that if you knew the length of the keyword you could crack it.  Suppose you knew somehow that the keyword was seven letters long - you would take the ciphertext and write the numbers 1,2,3,4,5,6 and 7 above it over and over again.  You would now isolate all the ciphertext letters with a "1" written above them.  Now you would know that all these letters had been encrypted using the same letter - the first letter of the keyword, whatever that is.  In other words, it becomes a monoalphabetic cipher! And as such you can use frequency distribution to work out what that letter probably is.  Then do the same with all the letters with "2" above them, and so on. But how are you to find out the length of the keyword?  And this is where Babbage and Kasiski had their inspiration. They realised that, provided the ciphertext was of a reasonable length it was pretty well inevitable that sooner or later the same two or more letters of the keyword would coincide with the same two or more letters of the plaintext - thus producing the same two or more ciphertext letters. So they looked for repeating groups of letters in the ciphertext and counted how many letters apart these appeared.  Of course some of these might be simply coincidence, but those that are the result of the same letters of the keyword hitting the same letters of the plaintext will be a multiple of the length of the keyword apart.  And there you are.

Friday, February 27, 2015

What's in a name?

A young Swedish lady who lives in this country had her online application for a Sainsbury's Nectar Card turned down because the computer program wouldn't accept her first name - which is Fanny.  It insisted that she entered "a valid first name".  I suppose Sainsbury's would argue that they are entitled to place what conditions they like on providing a card, but it would be interesting to know how the program has been set up regarding acceptable and non-acceptable names.  There are many people with "unfortunate" first names - Dick for instance (which these days is often a name in its own right, rather than a shortened form of Richard), and not all of them will have the get-out which she had of having a second name which she could use.  Come on Sainsbury's - get a grip!

Thursday, February 26, 2015

It's a secret (10)

So how do we use the Viginère cipher?  Well, we need a key word.  Ideally it will be a word with no "a"s and no repeated letters - so let's use "turkey".  Right, we take our message ("Put the kettle on back in ten minutes") and write our keyword over it again and again as often as necessary -
TUR KEY  TURKEY TU RKEY  TU RKE YTURKEY 
PUT THE  KETTLE ON BACK  IN TEN  MINUTES
and now we encipher the first letter (P) using the T line in the square - so we look P up on the top line and then follow it down to the T line, where it comes down as I. Then we encipher the next letter (U) using the U line and this comes out as O and the third letter T using the R line - and so on.  And our message becomes -
IOK DLC DYKDPC HH SKGI BH KOR KBHLDIQ
Now compare this with what we came up with in post 4.  There are five Es in the message, and back in post 4 they all came out as J - here they come out as C,Y,C O and I.  The double T in kettle came out back then as YY. here it come out as KD.  So frequency analysis won't be of any use here. Indeed this method of encipherment became known as le chiffre indechiffrable - the indechipherable cipher - and remained so for a couple of centuries.  But all good things come to an end...

Wednesday, February 25, 2015

Personal and local

It's being suggested that there should be some sort of memorial to Fred (see post 7/11/07) - preferably on his island.  I for one think that's a great idea - count me in.

Tuesday, February 24, 2015

It's a secret (9)

This is a Viginère square.  If you look closely you will see that it is simply a collection of all the Caesar shifts from 0 (or 26) - the "A" line, to 25 - the "Z" line.  How it became associated with Blaise de Viginère is a bit of a mystery, because he sure didn't invent it, but this was to be the basis of a new and for a long time, an unbreakable substitution cipher.  How - we'll see next time.

Monday, February 23, 2015

Year of the Shoat?

Well, last Thursday was Chinese New Year - it was the end of the year of the horse, and the beginning of the year of...  and therein lies the problem.  Not for the Chinese themselves - it's the year of the yang - this is a Mandarin Chinese character which looks a bit like an enlongated capital Y crossed by three horizontal lines.  And what does it mean in English?  Just "a horned animal" it seems.  So should it be translated as "sheep" or "goat" or perhaps "ram"?  It matters perhaps to the Chinese living here, because they are supposed to take on the characteristics of the animal of their birth year, and perhaps it is understandable that they don't wish to be considered sheepish, and so those born in 1955 and every 12 years before and since probably prefer to be though of as goats or rams.  Take your pick, it seems.

Sunday, February 22, 2015

It's a secret (8)

(Continuation from Friday)
Our substitution cipher is an example of what is called a monoalphabetic cipher - which means that the same plaintext letter will always result in the same ciphertext letter - and so will be easily solvable by frequency analysis.  When Mary, Queen of Scots was being held prisoner in the Tower of London she managed to send and receive letters from her supporters outside written in what was believed to be an uncrackable cipher - but although rather than letters, this cipher used esoteric symbols somewhat like Egyptian hieroglyphics which the users believed would make it secure, it was essentially monoalphabetic - the same plaintext letter would always produce the same symbol and so what she was writing and what was being written to her was being easily decrypted by the government of the day, and eventually resulted in her execution.  So the holy grail of cryptographers at that time was to come up with some method which would destroy this inevitable link between plaintext and ciphertext.  And how they went about this is for next time.

Saturday, February 21, 2015

Yesterday upon the stair...

...I met a man who wasn't there.  Yes I'm sure we all know the rhyme.  A post on a site I look at from time to time had an article on TV personalities that never in fact appear.  It's an American site but I wondered about UK examples.  And the two which immediately sprang to mind were both wives - Captain Mainwaring's "Elizabeth" and of course Arthur Daley's "'er indoors".  But I can go back further than that to "Budgie" back in the 70s where "Mrs Endell'l 'ave a tomato juice" was almost a catch-phrase  - the point being that we never saw her.  Is this sexist??

Friday, February 20, 2015

It's a secret (7)

I mentioned that the concept of substitution can be applied to words or phrases and not just letters. When it's used in this way the process tends to be referred to as a code rather than a cipher.  The codes can themselves be words (we might agree for example that "bear" means "night") or they may be random collections of letters (so "CFHN" might mean "office" for example).  Codes are generally considered more secure than ciphers since there is usually no pattern to them - meaning that if somehow you learn that CFHN means office it is of no help to you in finding out what "VKUP" means.  Ciphers on the other hand more often have some logic to them - so for example if you have established that cipher "j" is plaintext "e" this might lead you to suspect that ciphertext "k" is "f" and so on.  On the other hand, a cipher can be carried in your head, whereas a code needs a code book - so both approaches have their strengths and weaknesses.  An important point to make is that the same person or team was usually involved in encipherment and decipherment so they would be well aware of the weakness created by frequency distribution.  But what to do about it?  That's for next time.

Thursday, February 19, 2015

Where's the law?

Here's a funny one - a paramedic has appeared in court, been found guilty and been given a suspended sentence for ignoring a man who collapsed near him on the pavement outside the A & E department of a hospital and who subsequently died of a heart attack. Now let's be clear - this was a morally despicable thing to do, particularly for a trained paramedic. But how was it illegal?  Unlike some other countries' legal systems, there is not (as far as I am aware) any legal requirement for anybody to do anything to help a stranger who is in trouble. And I can't see why being a paramedic changes things.  Of course he may be (almost certainly will be) subject to disciplinary action by his employers, but that's a separate matter. Anybody know any different?

Wednesday, February 18, 2015

It's a secret (6)

(Continuation from Monday)
Neither of our examples of substitution or transposition enciphering would cause a knowledgeable decipherer much trouble. The achilles heel of such attempts is what is known as frequency distribution.  One of those things which "everybody knows" is that the most common letter in the English language is "e", but perhaps what is not so well known is that the frequency with which "e" appears in any reasonable sized piece of English is always the same - just over 12%.  And this is quite independent of content - it doesn't matter whether you are dealing with a treatise on the theory of relativity, or a pornographic novel - "e" will appear with a frequency of around 12%. And of course there's nothing special about "e" - the frequency with which any letter will appear is just as constant.  "p" for example will crop up around 2% of the time and "i" about 7% and so on.  The ten most common letters are e,t,a,o,i,n,s,h,r,d in that order.  What does this mean for our would-be decipherer? Well the first thing he or she will do is count up how many times each letter appears in the cipher text.  If the distribution is as it is for standard English, then that points to this being some sort of transposition cipher. If on the other hand, the letter "j" appears most often, then that suggests that this is a substitution cipher, and that "j" represents the letter"e" - as indeed is the case with our 5-place Caesar shift.

Tuesday, February 17, 2015

Eh up, pet!

According to a world-wide survey conducted by Time Out, the British accent is the most sexy. Yesss!!  But wait a minute - which British accent?  I can't imagine the Black Country accent sets the pulses racing, nor for that matter the Scouse accent or the Tyneside one.  Of course I could be wrong, but I fancy what they had in mind was more likely Estuary English à la Roger Moore or Benedict Cumberbatch. Apparently for some reason, they counted the Scottish accent as separate and this didn't do anywhere near so well, despite the fact that the rest of us Brits rank it as a comforting trustworthy accent, which is why so many call-centre staff are Scottish. And of course, it just ranked accents, not content, so the quality of chat-up lines didn't come into the equation.  Who could resist "Get yer coat - you've pulled"?

Monday, February 16, 2015

It's a secret (5)

(Continuation from Saturday)
A simple example of a transposition cipher is what is known as the rail fence cipher - or to be more accurate, the two bar rail fence cipher.  The plain text is written out on two lines - the first letter goes on the top line, the second letter on the bottom line, the third letter on the top line, the fourth letter on the bottom line, and so on.  So our message (put the kettle on back in ten minutes) would look like this -
P    T     H    K     T     L     O     B     C     I     T    N      I     U    E
     U     T     E     E     T     E     N     A      K    N    E     M    N    T    S
And then we write out the top line followed by the bottom line -
PTHKTLOBCITNIUEUTEETENAKNEMNTS
and tradition has it (this goes back to the early days of the telegraph when you paid by the word) that we then divide the cipher text up into five letter groups -
PTHKT LOBCI TNIUE UTEET ENAKN EMNTS
and there you are.  You might think that both the substitution cipher in the last post, and this one, would be pretty impenetrable, but in fact both are relatively easily solved. How?  Watch this space.

Sunday, February 15, 2015

Nul points?

It's always been somewhat of a curiosity that Israel take part in the Eurovision Song Contest although they are not a European country.  Apparently the answer is that the right to take part in the Song Contest is not contingent on being a member of Europe, but upon being a member of the European Broadcasting Union, which Israel are, as indeed are Egypt, Jordan, Libya and a few other countries in the region, although they have never taken part.  Anyway, all this pales into insignificance against the news that this year's contest will include Australia.  Australia?  Europe? The mind boggles!

Saturday, February 14, 2015

It's a secret (4)

(Continuation from Thursday)
The simplest form of substitution is what is known as the Caesar shift - each letter of the plain text is moved a set number of places down the alphabet.  Caesar himself (as in Julius) used to use 2 places, but it can be any number between 1 and 25 (26 of course would simply leave you back where you started).  So let's pick a number - 5 say, and let's make up a message -
PUT THE KETTLE ON BACK IN FIVE MINUTES
Now we need to write out the alphabet and then underneath it the alphabet moved on five places - 
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  A  B  C  D  E
And now we take each letter of the message in turn, find it on the top line and replace it with the letter immediately below, and the message becomes -
UZY YMJ PJYYQJ TS GFHP NS KNAJ RNSZYJX
The other party to the correspondence of course simply reverses the process - looking up each letter on the bottom row and replacing it with the letter immediately above. 

Next time we'll look at transposition.

Friday, February 13, 2015

Tulips on toast?

Almost unbelievable that there are people who might eat daffodils by mistake, but it seems there are. Public Health England has written to supermarkets advising them not to display daffodils near the fruit and veg. They're poisonous if eaten it seems. Apparently it is felt that the bulbs might be mistaken for onions, and the foliage for some type of Chinese vegetable.  Mind you, why you would put them with the fruit and veg is beyond me!

Thursday, February 12, 2015

It's a secret (3)

(Continuation from Tuesday)
So - cryptography.  Once again two Greek words - cryptos = secret and graphos = writing.  So here there is no attempt to hide the fact that a message is being sent - the idea is that the message ("the plain text") is transformed into some sort of gobbledegook ("the cipher text") which will mean nothing to anybody other than the person the message is intended for.  There are two basic approaches - substitution and transposition. With substitution, each letter, word or phrase of the plain text (depending on which particular "flavour" of substitution you are using) is replaced by something else - something else is substituted for it - hence substitution.  With transposition, each letter (and transposition almost always works at letter level) of the plain text remains the same, but the letters are shuffled around somehow - hence transposition.  We'll see how this works next time.

Wednesday, February 11, 2015

Shall we go to Ann Summers - or B & Q?

You would hardly credit it (or maybe you would), but B & Q have sent a memo to all their staff warning them that they may well see an increase in demand for rope, cable ties and duct tape following the forthcoming release of the film "Fifty Shades Of Grey". Furthermore they have urged staff to read the book so that they may be prepared for customer questions about "what DIY paraphernalia can and can't be used in the bedroom".  I think it was B & Q who had (and maybe still have) a policy of recruiting retired men for their expertise.  I don't really think this was the sort of expertise they had in mind!

Tuesday, February 10, 2015

It's a secret (2)

(Continuation from Sunday)
One of the most common ideas in steganography is to hide the message inside some other writing. The most famous example of this was during the Civil War when a royalist prisoner received an apparently innocuous letter which read the right way (taking the third letter following every punctuation mark) spelled out the whereabouts of a secret passage out of the castle where he was being held allowing him to escape. But such methods were time and labour intensive, and as the need for secret messaging became more and more a commercial matter (firms not wanting their competitors to know what they were up to) something easier and faster was needed, and steganography slowly gave way to cryptography - of which more next time.

Monday, February 09, 2015

Oh no, not again!

First it was "New Tricks" (see 8/9/12 and 3/9/14) and now it's "Death in Paradise". Why the hell can't they leave things alone?  I'd just about reconciled myself to Kris Marshall taking over the Ben Miller role - wasn't keen but it worked - after a fashion. But Sara Martins (Camille) leaving??  No, no, no!!  That's ripped out the main dynamic of the show - the suppressed sexual tension between Miller/Marshall and her.  Is somebody monitoring my viewing habits and going "Oh, he's watching that now - so let's mess that one up"?

Sunday, February 08, 2015

It's a secret (1)

(See post dated 4/2/15)
So A wants to send a message to B which is for B's eyes only.  The need or desire to do this has been around for ever, and many ways have been found to accomplish the task.  Back in the mists of time, we are told of a powerful ruler who, wishing to send a secret message to someone, would call for one of his slaves, have the slave's head shaved, write his message on the slave's scalp and then lock him away until his hair grew again.  The slave would then be sent as one of a party to whoever the message was meant for and who (obviously being in the know) would have the slave segregated, shave his head, read the message and then have the poor slave killed and his body burned so that no-one else would know what the message said. This is an example of what is known as steganography (two Greek words steganos = hidden, and graphos = writing).  The idea being to conceal from any outside observer the fact that a message is being sent.  A modern-day equivalent would be invisible ink - A would take a document which he might quite reasonably be sending to B and then on blank parts of the document write his message in liquid which vanishes as it dries but can be made visible again by some process (often just the appliance of heat).  Once again, the idea is that to an observer A is simply sending an innocent document to B - only B knows of the existence of the secret message,  More to come...

Saturday, February 07, 2015

How's it hangin' ?

Oh these earth-shattering questions - which way should your toilet roll be positioned? With the loose end over the top and to the front, or underneath - close to the wall? I'm an under man myself - always seems to me that it's more sort of discrete that way - not so much in your face as it were, but it appears I am very much in the minority.  As I'm on my own, it doesn't really matter that much but I would hate to think that any visitors might be embarrassed or confused.  What do you think?

Friday, February 06, 2015

Tick the box...

Not sure about this idea that pensioners should have to "opt in" to get the winter fuel payment.  When I first read it I thought it was a clever way round the problem, but the danger is that those who really need it may be too proud to ask and those who are on the margin may decide not to stick their heads above the parapet as it were. After all, many people would baulk at admitting that they need help with their finances.  So on balance, leave things as they are, I think.

Thursday, February 05, 2015

Meat for dinner?

The question has arisen again about whether we should allow farmed animals to be killed for food without pre-stunning them.  The procedure is called "halal" for Muslims and "kosher" for Jews.  Both words mean "proper" or "allowable" and both methods call for the animal to be killed while still "fully alive", and thus for strict adherents pre-stunning is not allowed. And the meat of the pig is taboo for both Muslims and Jews. But where do these ideas come from and why?  Problem is that for both peoples the stricture comes from their respective holy books and is thus inviolable. But why?  And it seems to me that it almost certainly all started out not as a matter of religion at all, but of public health. Both Muslims and Jews have traditionally lived in the Middle East where the weather is hot, and in such a climate in pre-refrigeration days, you had to be careful when eating meat, which could "go off" quickly and make you ill, if not kill you.  Pork is notorious for this (I remember as a kid and before we had we a 'fridge, we didn't eat pork unless there was an "r" in the month - i.e. not in the summer months).  So in those hot climates, pork was a no-no.  And for other meat it was essential that it was freshly killed and free from disease, and so to ensure this, the killing became a ritual. Whether there is any place for the idea in today's world of refrigeration and strict health controls is the question, but I think the concept is too deeply ingrained in the two religions for any possibility of change.  As has been mentioned before, there are those of both faiths who are prepared to use pre-stunning on the basis that alive does not necessarily mean conscious - after all you are alive when you are asleep - and maybe this is a way of satisfying both camps.

Wednesday, February 04, 2015

Promising the impossible?

A couple of weeks ago in the aftermath of the Charlie Hebdo massacre, the Prime Minister announced that, if the Conservatives won the forthcoming election, he would immediately introduce legislation giving the intelligence agencies power to break into and read any electronic communication between suspected terrorists. Problem is, he didn't say - and didn't really seem to understand that there was a need to say - how this was to be done.  I am surprised to find that I have not posted before about cryptography, which is somewhat of a hobby of mine, but the fact is that the majority, if not all of such communications will be encrypted and probably in such a way that they literally cannot be decrypted.  How such a situation has come about is a long story, and we'll go through the history a step at a time in a series of posts under the title "It's a secret".  So watch out for those.

Tuesday, February 03, 2015

Prisoner at the bar...

I really do regret having to return to the issue of rape,  but I feel the latest incursion by the Director of Public Prosecutions cannot be allowed to pass without comment. It is a basic principle of English law that it is for the prosecution to prove guilt, and not for the accused to have to prove innocence. But the DPP has now laid down guidelines which mean that in rape cases the defendant will effectively have to convince the police - and if the case goes further, the court - that the woman he is accused of raping did consent to having sex with him.  In other words he will in fact have to prove his innocence.  Rape is a very difficult area and I don't think the DPP's latest comments make it any easier.

Monday, February 02, 2015

Where's me soldiers?

Certain things that you do can be undone - that is to say everything involved can be put back into its original state.  These are called reversible processes.  Of course if you have reversible processes then they wouldn't be called that unless you also had irreversible processes - things that can't be undone. An example often given of the latter is a boiled egg - you can't unboil it.  Except it now appears you can - well, sort of.  Scientists in America have found a way of turning hard-boiled white of egg back into something like its original liquid state.  Not really unboiling it perhaps but apparently the technique may have useful ramifications in other areas.

Sunday, February 01, 2015

R.I.P.

Geraldine McEwan - to most people I imagine Miss Marple, but to me, back in my literary phase, she was Alice in "The Dance of Death" - she and Laurence Olivier were simply superb in what I always thought of as a black (very black) comedy.  Two actors at the height of their powers.  A good life, well lived.