Ashes to ashes

I’ve not written a blog post for quite some time. I’ve also not done any proper writing for a bit. With the blogging it’s just been a case of not getting around to it, and not wanting to go on the PC when I get home. With the writing it’s just been idleness to be honest. That and getting a bit bogged down with the new book I’m trying to write. It needs a synopsis but I haven’t written one yet, and I’ve been putting it off.

The only way I know to get past writer’s block is to write. It doesn’t matter if it’s rubbish, it doesn’t matter if no-one else sees it. What matters is putting pen to paper, or fingers to keyboard and going for it. One of my favourite quotes is by Picasso:, when inspiration strikes I want it to find me in my studio’. I started writing a scene that’s going to be in the new book and then on the 11th of January I heard that David Bowie had passed away.

Now, I’m not a huge David Bowie fan, in fact for most of my life I’ve been ambivalent towards him. Mainly because by the time I was really aware of him, he was a big pop star. I have though always had respect for him, and I’ve liked a lot of his songs. Really good stuff. As I’ve got older my music taste has matured/mellowed and I appreciate much more music than in my youth, so I can understand why lots of people are fans of David Bowie, and I’m much more aware of how influential he was and what a difference he made.

His death was not a complete shock to me. Sixty nine is a good age, much better than twenty-nine and there can be very little dispute that he achieved a great deal. Much more than the average person. Nevertheless, I feel somewhat sad, mainly for selfish reasons. Space Oddity by David Bowie was one of the songs from my early years, and David Bowie and his music is part of the soundtrack from my youth. His death is a reminder of my own mortality and, as if the mirror wasn’t already pointing it out glaringly, another sign of my ageing.

Perhaps inspired by this quote by David Bowie I wrote the following story. “Confront a corpse at least once. The absolute absence of life is the most disturbing and challenging confrontation you will ever have.”

The man sat in his chair and looked around the room which he was in. It was a waiting room, a large one with white walls. One wall had windows high up, so high that he could not see out of them from his seat. The other wall was quite some distance away, plain white and adorned here and there with nature photographs. He looked up at the ceiling overhead wondering if he could see the many murmurs of sound which gathered there fluttering around like bewildered butterflies. He smiled to himself at his imagination.

A nurse walked by, her apron starched brilliant white, her dress blue. She gave him a brief smile as she passed. The thought then struck him that he was a in a hospital seemingly un-touched by the many reforms to the National Health Service. Everything reminded him very strongly of the hospital he had gone to as a boy, many years ago but thankfully without the over-powering stench of disinfectant. Where was he, how had he got here? He did not know. That’s the problem with waiting there’s nothing to do except be patient or, he smiled again, be a patient.

He looked at the other people in the waiting room, most of them were sat by themselves looking around wondering; most of them elderly or middle-aged, the years of their youth far behind them. He saw nearby a young girl sat with her mother who was soothing her. The young girl was very frightened. A few seats away he saw a man with long hair and mutton-chop whiskers, wearing denim, cowboy boots and a hat with an expression that was a curious mixture of surprise, disbelief and underlying everything a sense of joy almost as if at any moment he was going to burst out laughing.

As he watched he saw a nurse come up to this man and speak quietly. He did laugh then, a great roaring bark that echoed all around the room. The man stood up to follow the nurse, who was already leading the way, and as they passed the two men exchanged winks and smiles as though they were sharing a joke.

After they had gone the man closed his eyes, leaning back in his chair trying to think, to recollect the chain of events that had brought him here but try as he might he could only snatch fragments of memories, faces that felt familiar, a scent that reminded him of his wife, and feelings; so many feelings, a sense of dread and fear, peace, acceptance, pain, loss, deep sadness and wonder.

“Hello, how are you?”

He opened his eyes to see one of the nurses bent down looking intently at him. She had clear blue eyes, an open honest face and wisps of blonde hair escaping from underneath her hat.

“I don’t know,” he replied. “I’m trying to think, remember how I got here but I don’t know.”

“That’s quite common, for the moment try not to think. Listen to the birdsong, we have nightingales outside, just for you.” She smiled.

“Really?”

“You like music don’t you? Listen and relax. I’ll be back soon and then the,” she paused, “consultant will be ready for you.”

“Is this a hospital?”

“In a fashion; we help people feel better.” She reached out and patted his shoulder before standing up, turning and walking away.

He watched her go and again fragments of remembered feelings came back to him: temptation, fascination, desire and pleasure but it was like flicking through an old album of photographs: pausing briefly at one or the other, before moving on. She was gone and now as he listened he could hear the sweet thrilling cascade of notes from the nightingales; first one, then two, then a pause before three, then two, then one, then three then a pause, a moment to allow the golden notes to soar up and up, away from the earth. He wished he could see them. How long had he been sitting here? He felt like getting up, going for a walk to discover just how big this room was but then he heard the heels of the nurse on the floor, then saw her coming back looking efficient and busy.

“He’s ready for your now. Will you come with me please?”

“Who is he?”

“Come and find out. There’s nothing to worry about. I’m sure you have had enough of sitting, waiting.”

“Yes.”

“Good. Come along.” She stood to one side, gesturing with one hand that he should rise, and the man at first with some hesitation for he remembered now that he had been very ill, slowly with both hands either side of him raised himself up onto his feet. Then he was struck by another feeling, one he had never forgot but had not experienced for many years. He felt like crying.

“But I’m old,” he whispered.

“You were,” the nurse corrected. “Now, we really are rather busy.”

“I feel like I could hop and skip and dance,” he said, spinning around in pleasure. The nurse smiled kindly at him then turned and began walking briskly, the man hurried to catch up with her. She maintained her pace and he did not have much time to look around at the cavernous waiting room or the views through the windows. She stopped next to an open door and gestured that he was to go in.

“Thank you,” he said.

The corners of her mouth twitched in a quick smile before she spoke. “He’s waiting. There’s nothing to be concerned about.”

The man passed through the door into a small comfortable room with easy chairs next to a warm glowing coal fire. Through a window he could see trees and flowers, somewhere a wren was singing and sparrows twittering. A man sat in one of the chairs, reading a book. He had thick closely cut white hair and beard. He looked up hearing his guest arrive.

“I’m pleased to meet you. Please sit down. Would you care for something to drink? Can I tempt you to a single malt? We have some extremely fine ones.”

“No, thank you I don’t drink. I haven’t touched alcohol for many years.”

“Yes, I’ve noted that but I thought perhaps under the circumstances. Any particular reason why you gave up alcohol?”

“I didn’t like the person I became, or rather I should say I didn’t like the parts of my personality it brought out.”

“Tea then? Or coffee, juice?”

“What sort of hospital is this?”

“It’s not a hospital, although a great many people make that assumption. May I call you David?”

The man paused then smiled. “I seem to remember that was my name.”

“That’s correct. My name is Peter. I’m going to have some tea. Will you join me?”

“Yes please. What is this place Peter?”

“A place to help, somewhere to begin to make sense of what’s happened.”

“Is this heaven?”

Peter laughed. “A cup of tea, and an armchair by an open fire. I suppose it’s some people’s idea. Do you object?”

“No,” David said, looking around the room again. “No, it’s very familiar, it reminds me of my childhood.”

“So much of our adult lives are shaped by our childhood. It is perhaps the most important time of a person’s life but the time when you have least control over it. A child is at the mercy of its parents, school, the circumstances and area in which it lives.” As he spoke Peter, got up and went into a small kitchen.

David lay back in his chair and closed his eyes. He had been ill, very ill, he remembered now and sometimes the treatment was more painful than the illness. He remembered his wife and how much he loved her. The years they had spent together, and he remembered his daughter and his son. The flood of memories became a torrent and tears sprang to his eyes before rolling down his cheeks.

“I’m back now,” Peter said, carrying a tray and setting it upon a table. “Ah,” he said again. “I’ll get you a handkerchief. It’s good to cry, don’t be embarrassed. It’s part of the healing process.”

David took the offered handkerchief and after wiping his eyes spoke.

“Will I ever see them again?”

“Yes.”

“I’ve died, haven’t I?”

“Yes,” Peter said. “Tea?”

David looked shocked, then angry before suddenly bursting into laughter. Peter smiled before busying himself with the cups and tea-pot. “Death is part of life, it’s completely natural. Without death there can be no re-birth.”

“But it’s the great un-known,” David said. “We don’t know what happens afterwards and there are so many conflicting views.”

“Some are correct and soon you’ll discover which but for the moment the most important thing is to accept,” Peter said, handing David a cup of tea and sitting down in his chair.

“I accept it but I feared it, not so much for myself but my family; the separation, the permanent absence.”

“You may see death as you being in one room and your family in the other.”

“How does that help? I can’t go back to that other room!”

“No, not yet, but if you knew your wife and family were next door it would be a comfort, although you would be sad that you could not see them, and angry that you were being prevented.”

“But I didn’t want to die. I didn’t want to leave them all alone.”

“They are not alone. The body is at best a shell, a vehicle provided for the benefit of its passenger. You have left your body behind. You can’t go back to it. But you have left behind much more than a body. You have left so many memories, so many times when you have touched other lives consciously and unconsciously. The memory of you will live on, and in time be a comfort to those you have left.”

David sighed. “I miss them.”

“And they miss you. You were lucky, you lived a long life and a very productive one. You touched a great many lives.”

“I made many mistakes.”

“All humans do. To err, to make mistakes, is human. You cannot have life without death, light without dark. They are opposites that define the other.”

 

 

Advertisements

Encryption and Decryption in C#

I have been looking at encrypting and decrypting data as part of a project that I’m doing at work. As is quite common there’s a ton of stuff on the internet but the devil as always is in the details. What appears to work for one person won’t necessary work for another.

I don’t want to talk too much about how encryption and decryption works, partly because I’m not an expert so there are a few things I’m bound to get wrong. Also it is a separate topic in itself. There are however two fundamental things that you need to be aware of: these are the Public Key and the Private Key. The Public Key as its name suggests can be shared with the public, the private key should be kept private. The other thing to be aware of from a coding point of view is that there are a number of different ways to do this. I tried quite a few of them but not all. The reason for this is trying to keep the details used to encrypt safe.

The private key can be used to decrypt messages and the public key can be used to encrypt messages. I think that when passing encrypted data between two parties, Alice and Bob, then both will need to have the same private key to decrypt. When reading articles about cryptography it’s very common to read about Alice and Bob.

The purpose of this article is make some notes about the code that works for me, and explain some of the areas which tripped me up and caused me some problems.

The code at the bottom of this article is the working version I got to this morning. There are a things to note. First, I’m using two X509Certificates, an CER file and a PFX file. You could just use the PFX file, since this contains both the private and public key, the CER file doesn’t contain the private key. If you had a scenario where Bob needed to send encrypted messages to Alice then he would just need the CER. Alice could keep her private key and decrypt messages she receives from Bob.If Bob wanted to read encrypted messages from Alice then he would also need the private key.

The most common exception I got was ‘the key does not exist’. There can be a number of reasons why this happens but all the solutions I saw online didn’t help me. It wasn’t until I added a third parameter in the X509Certificate import: the X509KeyStorageFlags.Exportable parameter when things started working. And I only found out I really needed this through trial and error and getting this exception ‘key not valid for use in specified state’. And I only started getting that error when I tried using the ImportParameters method of the RSACryptoServiceProvider. There were also a number of problems with the

These links on StackOverflow helped me and contain information that I found useful

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.IO;

namespace EncryptionAndDecryption {
  class Program {
    static void Main(string[] args) {

      string textToEncrypt = “The quick red fox jumps over the lazy brown dog”;

      string encryptedText = Crypto.Encrypt(textToEncrypt);
      string decryptedText = Crypto.Decrypt(encryptedText);

      Console.ReadLine();
    }
  }

  static public class Crypto {

    public static X509Certificate2 GetPublicKey() {
      return new X509Certificate2(@”c:\TestCertificates\testCertificate.cer”,
                                                           “”,
                                                         X509KeyStorageFlags.Exportable);
    }

    public static X509Certificate2 GetPrivateKey() {
      return new X509Certificate2(@”c:\TestCertificates\testPFX.pfx”,
                                                          “password”,
                                                         X509KeyStorageFlags.Exportable);
    }

    public static string Encrypt(string textToEncrypt) {
      ASCIIEncoding byteConverter = new ASCIIEncoding();
      byte[] encodedBytes = byteConverter.GetBytes(textToEncrypt);
      X509Certificate2 cert = GetPublicKey();

      byte[] encryptedBytes;

      RSACryptoServiceProvider rsa = cert.PublicKey.Key as RSACryptoServiceProvider;
      encryptedBytes = rsa.Encrypt(encodedBytes, false);

      return Convert.ToBase64String(encryptedBytes);
    }

    public static string Decrypt(string encryptedText) {
       byte[] encryptedBytes = Convert.FromBase64String(encryptedText);
       X509Certificate2 cert = GetPrivateKey();
       RSACryptoServiceProvider rsa = cert.PrivateKey as RSACryptoServiceProvider;

       byte[] decryptedBytes;
       decryptedBytes = rsa.Decrypt(encryptedBytes, false);

       ASCIIEncoding byteConverter = new ASCIIEncoding();
       return byteConverter.GetString(decryptedBytes);
    }

   } //End of class Crypto
}

Tony Blair – Peace Envoy

I’ve just read this article about Tony Blair, our beloved former Prime Minister, who is stepping down from his role as Middle East Peace Envoy.

http://www.bbc.co.uk/news/uk-32905468

Apparently he feels that he can best serve by not having any formal role. Now, I speak as someone who doesn’t really know what he’s done behind the scenes since 2007 but I do think there is something he could do that might make a big difference. This is to apologise for the mess that the Middle East is in ever since he and George W Bush invaded Iraq. There would be no ISIS, no crisis in Libya and Egypt if they hadn’t so dramatically upset an already very delicate and sensitive region. To this day I can find no credible reason why they did this AND why they thought this was a very good idea.

As a peace envoy to most Arab states he must be as welcome as an undertaker at a wedding measuring the guests up for their coffins. He should never have accepted the role in the first place and slunk away to hide under the nearest stone.

The Children of Green Knowe by Lucy M Boston

It is almost April, just one night to go and then a third of this year will be behind us. Where has it gone? January and February didn’t appear to be flying by, but March seems to have done just that. It doesn’t seem that long since I was turning the calender and looking forward to spring. The old saying is that March comes in like a lion and goes out like a lamb, or March comes in like a lamb and goes out like a lion. Well, the wind has certainly been doing some roaring and growling today. There’s been hailstones, driving rain and a cold north wind. Not the sort of weather for being out and about. Just the right sort of weather in fact to curl up and read a good book.

It is many many years since I first learned about ‘The Children of Green Knowe’. I remember it being read to us at primary school. I think it was autumn, and for a long while afterwards I could never look at trees in quite the same light. It was a book that stayed with me for quite some time. But I grew up and discovered other books and interests, and this remained a memory of childhood, along with looking at a very tall old poplar tree near our school with deep suspicion.

Things change and the old poplar tree, and the oatcake bakery it stood next to have both gone. Progress and development seem to involve so much destruction. The school that I once thought was so big and terrifying now seems very small, and the playground where battles and epic cup finals were fought is a small square of tarmac.

This all sounds very nostalgic, which is more a reflection of the mood I’m in at the moment, rather than this book although perhaps it has added to my current mood. This is a book that belongs to my twin brother, and I saw whilst browsing his book shelves. I’m glad he let me borrow it for a while because it has been a pleasure to read. It is possibly the most charming story about ghosts a child (or adult) could wish to read.

Some children’s books do not age well, or end up showing their age. As a child I enjoyed ‘The Famous Five’ and ‘The Faraway Tree’ by Enid Blyton but now reading them with my son, I feel they are dated. Not so much the language as the attitudes. As a child it was much easier to see things in black and white and accept bad characters and good characters. Now, it seems too simple and un-fair.

The Children of Green Knowe however has aged well, and I would say can be enjoyed by all ages. As a child I found it very atmospheric and it certainly caught my imagination. As an adult I appreciated the same things, perhaps being more aware of the quality of the writing, and the deftness of the plot. The story starts with a boy, Tolly, travelling by train across the fenlands of East Anglia through heavy rain and floods to go and stay with his Great Grandmother at her ancient home, that is now called Green Noah.

Tolly soon finds that he isn’t the only child at the house but unlike himself the other children were alive many years ago. He learns the history of his family and the children, his ancestors, from tales his great-grandma tells him. Unlike Enid Blyton the language in this book, whilst somewhat old-fashioned is perfect in that it helps set the scene. Tolly learns about his past, and I am learning about his past, it is only right that the language reflects the age he lived in. But the language is not condescending, the author addresses the reader in terms that both child and adult can understand.

Rather than talk too much about the plot and the writing, the best thing I feel is to write the first paragraph.

“A little boy was sitting in the corner of a railway carriage looking out at the rain, which was splashing against the windows and blotching downward in an ugly, dirty way. He was not the only person in the carriage, but the others were strangers to him. He was alone as usual. There were two women sat opposite him, a fat one and a thin one, and they talked without stopping, smacking their lips in between sentences and seeming to enjoy what they said as much as if it were something to eat. They were knitting all the time, and whenever the train stopped the click-clack of their needles was loud and clear like two clocks. It was a stopping train – more stop than go – and it had been crawling along through flat flooded country for a long time. Everywhere there was water – not sea or rivers or lakes, but just senseless flood water with the rain splashing into it. Sometimes the railway lines were covered by it, and then the train-noise was quite different, softer than a boat.”

I enjoyed reading and re-discovering this book so much that I think I might read it again before handing it back to my brother. I hope you enjoy reading it too.

Joining a Server to a Domain

This post is basically for my own reference but if it helps someone else that’s great.

On the server open up a command prompt and type ipconfig /all this will display a list of settings. You need to check to see which is the Default Gateway. In this case I needed my Default Gateway to be the Domain controller for my Domain, and I needed to change it. To do this you need to go to the Network and Sharing Centre. This can be reached by going to the Control Panel (my server was Windows 2008 R2) then Network and Internet, then Network and Sharing Center.

NetworkAndSharingCentre

On this panel you will should see a Local Are Connection. Click on this and then go to Properties. On this screen look for Internet Protocol Version 4 (TCP/IPv4) and then click on Properties. This shows a screen where you can change the Default Gateway and Preferred DNS server. I altered both to point to my desired Domain Controller. I then saved the changes.

InternetProtocolVersion4Properties

I was then able to go to the System window for my server, this can be reached either through Control Panel -> System and Security -> System or in Windows Explorer right-click on Computer and go to Properties. On this screen you will be able to ‘Change Settings’ to specify the Domain you want your server to join.
SystemChangeSettingsPanel

Some thoughts on Programming

As programmers our work consists of the following: talking, thinking, coding and difficult stuff. All four things are necessary.

Talking is essential, we swop ideas, learn new things and generally train our brains in new skills.

Thinking: this is where we are mulling over problems, planning possible solutions or re-evaluating. One of the key times for me doing this is at home when I’m not in front of a computer or in a noisy open plan office. I like to garden and quite often great ideas will pop up ‘out of the ground’.

Coding, this is putting into practice everything we’ve talked about and practised. Some programmers spend to a lot of their time coding, others take a more surgical approach. Apparently programmers only spend ten per cent of their working day writing programs, which sounds wrong but is about right.

Difficult stuff: This is a catch-all term for all the bits of work that is either truly difficult, hard-to-solve bugs or the flash stuff where we show off. “Look at me, I can do this’. Some of the difficult stuff is difficult because we simply don’t do it very often. Pushing software live is one of these things. Some of the difficult stuff becomes much easier with practice.

Other tasks remain difficult not because of the technical complexity but the complexity of the relationships between all the interested parties. Programmers, despite quite often wanting to, rarely work in isolation and what they do affects others. None more so when pushing software live.

Watership Down – Richard Adams

Some time ago I read ‘Duncton Wood’ by William Horwood, and as I’ve said before I remember reading this book and enjoying it when I was younger, but now that I’m older I was less keen. One of the reasons for this was the length. When I was younger that didn’t bother me, in fact the longer the better since that meant I could stay longer ‘inside’ the book. Now, and perhaps it is because of re-reading the book, I was less thrilled and felt that the book had been dragged out longer than need be. It was therefore with a slight sense of trepidation that I picked up my old battered copy of ‘Watership Down’. It has been probably about twenty years since I last read this book and I was afraid that re-reading it might alter the fond memories I had of the book.

I needn’t have worried. Perhaps the mark of a great book is the joy to be found re-reading it and discovering new things and new pleasures. Perhaps, it is credit to the author who made the story just long enough, avoided too much sentimentality and who wrote a great story. The fact that the characters are rabbits does not disguise the fact that the challenges they face and over-come are human. We all face threats and problems and have to find solutions if we are to move on.

One thing that I noticed more with this re-reading is Richard Adam’s love of the English countryside beyond the obvious use of plants for the characters’ names. The seasons, the sounds and the smells help bring the book to life. Another thing I discovered is that Richard Adams is now 94 and hopefully still hale and hearty. Long may that continue.

When writing my book reviews I don’t say much about the plot. I don’t particularly want to spoil it for anyone picking it up for the first time. I first read my Nan’s copy sometime in the late 70s or the very early 80s. I remember being very proud that she let me borrow the book and then the enjoyment of reading it. My own copy has a still from the animated film, which I remember watching at the local cinema and being a touch disappointed with. I couldn’t quite understand the need to change the plot, it simply doesn’t need it, although the animation was rather good. Another thing my book has is an ‘official’ Watership Down bookmark that I made. It was rather sweet to find it and realise how much I enjoyed this book.

Curiously though I’ve never read any other Richard Adams’ books. Perhaps I ought to.