Member-only story

Promising Cryptography: JavaScript Promises in Encryption

--

I remember, in the past, it often happened that Microsoft Windows took longer to boot up with each new version — as it had to check more things. However, at Apple, Steve Jobs kept pushing his team to make the boot-up time as instant as possible. It perhaps showed the difference between Microsoft and Apple at the time and where, for Steve, it was the user experience (UX) that mattered just as much as the engineering of the system. So, for the Web, how do we get around code hanging in the browser while we wait to finish something without stopping everything else? Well, for this, we turn to promises in JavaScript.

JavaScript has been the saviour of the Web. It has freed us from all the pesky client-server communications and now allows us to run code in a browser without much delay. These days, users want almost instant page loads and where there is no noticeable delay in the code running. So, how can JavaScript execute code which might take a bit of a delay and not get hung up waiting for something to finish?

One of the most lengthy delays we could have is in the generation of an encryption key, especially for public key encryption. So, JavaScript overcomes this problem by creating a “promise object.” For this, we define that something will be provided soon and then define the code that will run when the promise has been…

--

--

No responses yet