• Question: How hard is it to make a complex code?

    Asked by to Ian on 25 Jun 2014. This question was also asked by .
    • Photo: Ian Stephenson

      Ian Stephenson answered on 25 Jun 2014:


      (I’m guessing you mean code as in encryption rather than computer code – ask again thats not right!)

      Pretty hard.

      Most regular codes are based on a “shared key” or shared secret. That is if I want to send you something securely we both need to know how to encrypt and decrypt the messages. At the simplest level that might be a simple exchange code, so I tell you to replace all the A’s with B’s, all the B’s with C’s and so on. Once you’ve done that you can send me the message, and I can decode it.

      THERE’S A PROBLEM HERE!

      How do I tell you that you should encode the message that way? I send you a message… but how do I send you that message? If anyone else reads that message then they’ll know how to encrypt and decrypt messages too…. To send you a secure message, first I need to send you a secure message… At this point we get stuck. For a long time there were guys with guns, and metal suitcases who went around the world carrying “keys” (the encode/decode instructions) on pieces of a paper. If I wanted to send you a secure message I ‘d send the key by secure courier, then once you had the key I could send you the message.

      That all changed with the invention of public key encryption. It was invented by a bunch of mathematicians who asked the question, could I use maths to make a code where knowing how to encrypt a message wouldn’t be any help at at all decoding the message. THAT’s REALLY CLEVER.

      I can now put a message on my website saying “here’s now to encode message you want to send to me”. Any one can read it, and use it to encode message, but even they can’t decode them again.

      Every message as a PUBLIC key which everyone knows and a PRIVATE key that only one person knows. It’s like a lock that has two keys – one to lock it, and a completely different key to unlock it.

      If you want to send me a message you need my PUBLIC key – I can tell everyone that. You encrypt your message with the public key. It’s now locked. Only someone with the private key can unlock it… That would be me!

      Even cleverer, you can double lock the message using my public key, and YOUR private key. Nowto unlock it I need MY private key and YOUR public key. This doesn’t make it harder to break but it PROVES it was locked by you, as only you have your private key so only you could have locked it.

      The maths behind it it complex, but it requires a “trapdoor” function – this is a bit of maths that is easy to do, but hard to undo, and typically involves prime numbers. Imagine I asked you to tell me two numbers that multiplied together make 65. It’s not that hard, but its a lot harder than me asking you what 13×5 is. And when computers to it they use numbers hundreds of digits long, so finding the factors is really hard, but doing the multiply is easy.

      Public key encryption’s an essential part of the web, as its used whenever you log into a website like amazon, ebay, goole, or a bank or shop so that your messages are secure.

Comments