A fundamental topic of IT security that often makes people hard to understand the difference between symmetric, asymmetric encryption, and hashing [1]. Before we go in details, we need to know that if the important data such as password is not encrypted or hash, the data will be in risk since the password is in plaintext and it is human-readable that can be used to login into the server without permission very easily. For HTTP in plaintext, the data can be seen in the URL when sending to the server using POST request. This allows not only the owner of the site sees it, but also other people might see it too. It is also a good chance for hackers to steal some important information including bank account if the users use the same passwords as the one they use for the website.
Hyper Text Transfer Protocol Secure (HTTPS) is the secure version of HTTP, the protocol over which data is sent between your browser and the website that you are connected to [2]. The ‘S’ letter stands for ‘Secure’. It means that all communications between your browser and the website are encrypted. HTTPS is often used to protect highly confidential online transactions such as online banking and online shopping.
Now, let’s look at different types of encryption and hashing.
Symmetric encryption is also be referred to as private key, shared key or shared secret encryption. In symmetric encryption, a single key is used both to encrypt and decrypt traffic.
Symmetric encryption algorithms is really fast, and their relatively low complexity allows for easy implementation in hardware. However, they require that all hosts participating in the encryption have already been configured with the secret key through some external means.
On the other hand, Asymmetric encryption is also known as public-key cryptography. The main difference between the two encryptions is that two keys are used in Asymmetric encryption. One is for encryption and the other one is for decryption. The most common asymmetric encryption algorithm is RSA.
Asymmetric encryption executes a high computational burden, therefore, it tends to be much slower than Symmetric encryption. Its major strength is its ability to establish a secure channel over a non-secure medium such as the Internet. This is done by the exchange of public keys, which can only be used to encrypt data. The complementary private key, which is never shared, is used to decrypt.
Hashing is a form of cryptographic security which differs from encryption. While encryption is a two-step process used to first encrypt and then decrypt a message, Hashing condenses a message into an irreversible fixed-length value, or so called hash. Two of the most common hashing algorithms seen in networking are MD5 and SHA-1.
Hashing is only used to verify data and the original message cannot be retrieved from a hash. When used to authenticate secure communications, a hash is normally the result of the original message plus a secret key. Hashing algorithms are also commonly used without a secret key simply for error checking.
A cryptographic hash (sometimes called ‘digest’) is a kind of ‘signature’ for a text or a data file. SHA-256 generates an almost-unique 256-bit (32-byte) signature for a text [1].
To implement the SHA-256 into ionic apps, I need to run this command to install the crypto library.
npm install crypto-js
References
[1] Chris Veness, 2. (2017). SHA-256 Cryptographic Hash Algorithm implemented in JavaScript | Movable Type Scripts. [online] Movable-type.co.uk. Available at: http://www.movable-type.co.uk/scripts/sha256.html [Accessed 31 Aug. 2017].
[2] Instantssl.com. (2017). HTTP to HTTPS | What is a HTTPS Certificate. [online] Available at: https://www.instantssl.com/ssl-certificate-products/https.html [Accessed 5 Sep. 2017].
[3] Packetlife.net. (2017). Symmetric Encryption, Asymmetric Encryption, and Hashing — PacketLife.net. [online] Available at: http://packetlife.net/blog/2010/nov/23/symmetric-asymmetric-encryption-hashing/ [Accessed 5 Sep. 2017].
[4] Ionic. (2017). Can I use sha256 function in Ionic?. [online] Available at: https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/9 [Accessed 31 Aug. 2017].
[5] npm. (2017). crypto-js. [online] Available at: https://www.npmjs.com/package/crypto-js [Accessed 31 Aug. 2017].