Skip to content

a review of its history

27 mayo, 2021

The cryptography It is a need derived from making communications in writing (in its origin) created to preserve privacy of the information that is transmitted, guaranteeing that an unauthorized person cannot read the content of the message.

In history we have had many examples of ways to encrypt messages such as spartan methods 2,500 years ago, the encryption of Polybios (from the Greeks) or the Caesar’s cipher (from the Romans), and without forgetting the most famous encryption machine in history: the Enigma machine.

History of cryptography

In this article I will only deal with the history of cryptography and will put some practical examples, later I will delve into the different types of modern cryptography and later their use.

The Spartan Scythian (5th century BC)

Write it - history of cryptography

The first encrypted messages that we know date from the 5th century BC, of ​​Spartan origin, which put into practice a simple and rudimentary method that consisted of taking a stick (called a scythe), a leather or papyrus ribbon was screwed on it and later wrote longitudinally (as in the image).

And finally the tape was unrolled, with a handful of nonsensical letters and sent through the seur messenger on duty at a trot. Supposedly the information could only be decrypted with a rod of the same diameter as the original one on which it was written (obviously if you try to square the letters you end up getting something clear, but at the time you did not know much to read, nor the language origin and much less had the general culture necessary to think that the information was encrypted).

Use

The diameter of the scythe is the key to this encryption method (or just every few characters starts a turn).

In the example we will encrypt the following text input:

Genbeta Dev – History of cryptography – Method used by the Spartans

And as the key or diameter of the scythe (n) we will take the number 7, that is, in each turn of the tape screwed on the rod we will put 7 characters. The result is as follows:

G tMose-doé pn egtpabH rooreiladrttsafo aat í ln ocauooDrr ssseii-a vap de

You can put the technique in motion with this example that I have made and the code JavaScript is the following:

function escitala(txt,n){ 
    //Convertimos "n" en entero 
    var n=Math.floor(Number(n)) 
    //"e" nos indica si entra justo en las filas 
    var e=(txt.length%n>0?1:0) 
    //Calculamos el número de filas resultantes 
    var lin=Math.floor((txt.length/n)+e) 
    //"r" contiene la respuesta 
    var r="" 
    //Añadimos el carácter a la respuesta 
    for(var a=0;a'+txt.charAt(a+(b*lin))+'' 
    return r 
}

The function needs two arguments, the text and the diameter that we will use as a key (n) as follows: escitala([Texto],[Entero: diámetro]).

The Polybios Cipher (2nd century BC)

This system is the first character substitution cipher. The invention is attributed to the Greek historian Polybios and the encryption system consists of substituting a character for the number or letter of a column or row (as if we were playing sink the float).

Polybios - history of cryptography

In the example of this system we will introduce the following string:

Genbeta Dev History of cryptography Method used by the Greeks

Note: we have to take into account that in this method the letter “is substitutedJ” by “I“. The result of encrypting with the table in the image (the theoretically real one) is as follows:

BBAECCABAEDDAA ADAEEA BCBDDCDDCDDBBDAA ADAE CAAA ACDBBDCEDDCDBBDBAABABDAA CBAEDDCDADCD DEDCAAADCD CECDDB CACDDC BBDBBDAEBBCDDC

And you can try it with this example to encrypt and decrypt with the Greek system (Polybios).

var let="abcdefghiklmnopqrstuvwxyz" 
var tra="ABCDE" 
//función de encriptación 
function polybios_enc(txt){ 
    //Comprobamos que el texto es válido 
    var pat=/^[0-9A-zs]*$/ 
    if(!pat.test(txt)) return 'Texto no válido' 
    //Lo pasamos a minúsculas y convertimos la "j" en "i" (como requiere el método) 
    var txt=txt.toLowerCase().replace('j','i') 
    var r="" 
    for(var a=0;a0){ 
        if(t.substr(0,1)==' '){ 
            r+=' ' 
            c=1 
        } 
        else{ 
            var s=t.substr(0,2).split('') 
            r+=let.charAt((tra.indexOf(s[0])*tra.length)+tra.indexOf(s[1])) 
            c=2 
        } 
        t=t.substr(c,t.length-c) 
    } 
    return r 
}

Both functions only need the argument with the text to be encrypted or decrypted.

Caesar’s cipher (1st century BC)

The Romans 2100 years ago devised their own encryption system (on the same level as the previous ones) that consisted of substituting each letter for another that is the result of shifting three positions to the right from the origin character in the alphabet (with the image of below will be perfectly understood).

Caesar's Cipher - History of Cryptography

This technique could be improved by changing the “shifted” alphabet to a random one, for example, but the method in principle is shifting three characters to the right (and to decrypt it to the opposite, to the left).
Note: this system can also support spaces, which will be added as one more character or if not used they will be omitted.

To give another example, we are going to encrypt the following string (we will count the spaces):

Genbeta Dev History of cryptography Method used by the Romans

And the result is the following:

jhqehwdcghycklvwruldcghcodcfulswrjudildcphwrgrcxvdgrcsrucorvcurpdqrv

And finally I have made this other functional example of Caesar’s encryption system, which admits a different displacement number (n), be positive or negative (if we encrypt it with n=3 we must decrypt it with n=-3).

function cesar(txt,n,space){ 
    //Comprobamos que el texto es válido 
    var pat=/^[0-9A-zs]*$/ 
    if(!pat.test(txt)) return 'Texto no válido' 
    //Adaptamos el texto según si admitimos espacios 
    var let="abcdefghijklmnopqrstuvwxyz"+(space?' ':'') 
    var txt=txt.toLowerCase() 
    if(!space) for(var a=0;a

This function is used to encrypt and decrypt (we must simply subtract the offset) and it needs the following arguments: cesar([Texto],[Entero: desplazamiento],[Booleano: con o sin espacios]).

Resume

This is one little introduction to cryptography mixed with a bit of history (and it is only three examples, if we started to name methods and methods that did not need computation we would have for a while). In the next part I will comment on the types of encryption … modern.

In Genbeta Dev | Cryptography