From The 18th Century to the 21st Century: Morse Code To Ethereum

I love creating and cracking ciphers, and have generated an online challenge that has over 100 different ciphers in it:

Photo by Chris Curry on Unsplash

From The 18th Century to the 21st Century: Morse Code To Ethereum

I love creating and cracking ciphers, and have generated an online challenge that has over 100 different ciphers in it:

https://asecuritysite.com/challenges

If fact, there have been over one million cipher challenges delivered over the past few years. So, now I’ve decided to move the generation of these challenges into the 21st Century and implement them with a smart contract on Ethereum.

I have thus started to migrate my code infrastructure so that rather than using a database of challenges, I call up a smart contract to generate a unique set of cipher puzzles for users to solve. The user will never really know that the back-end of the ciphers is delivered from a smart contract. Overall it will not cost me anything to run, and I know the contracts will always be available and ready to be run. I will have no need for a server to deliver the challenge, and where I can thus move the cipher computing infrastructure to Ethereum. There will be no need to run it within AWS or on an IIS Web server — I will only need a lightweight user interface and a little bit of middleware.

So, here’s my Morse Code challenge generator:

In this case, we have a range of words, and where a word is selected at random. Next, it is easy to then go through every character in the word and find its position in the alphabet, and which is then mapped to a list of Morse code presentations.

string [26] memory morse= ["(.-)","(-...)","(-.-.)","(-..)","(.)","(..-.)","(- -.)","(....)","(..)","(.- - -)","(-.-)","(.-..)","(- -)","(-.)","(- - -)","(.- -.)","(- -.-)","(.-.)","(...)","(-)","(..-)","(...-)","(.- -)","(-..-)","(-.- -)","(- -..)"];

We can first apply our code to Remix (https://remix.ethereum.org) and compile the code:

We can then start ganache, to create our local blockchain:

Next, we can deploy to the local blockchain:

And finally, we can test the code:

This gives:

Find the plaintext for the Morse code of: 
(-.-.)(- - -)(- -)(.- -.)(.-..)(.-)(..)(-.)(-)(...)
The mapping is: complaints

which is correct as “-.-.” is a ‘c’, and “ — — — “ is a “o”. The word is “complaints”.

Next, we can deploy to the Ropsten test network:

And then the contract will wait to be deployed:

And which is then mined:

We can then go to the contract:

And then Verify and Publish:

We then enter the details of the contract:

And then paste the Solidity code in:

And finally, the contract is made [here]:

And now we can test:

The generator is:

Find the plaintext for the Morse code of: 
(-.-.)(- — -)(-.)(-.-.)(.-.)(.)(-)(.)
The mapping is: concrete

As before “-.-.” is “c”, and “- — — “ is “o”. The rest of the word generates “concrete”. Now we try another one:

And it works. If you want to try the smart contract, it is here:

https://ropsten.etherscan.io/address/0x428156e810a3fbeef9bd1fb4a61a74f171a3d023#readContract

If you are interested, here is it in action with a user interface:

https://asecuritysite.com/challenges/morse