The Decrypt service is meant to be used with the Encrypt service. It uses symmetric encryption which is designed to allow anyone with access to the encryption key to decrypt and obtain the original input value. It can decrypt encrypted strings provided the decryption key is the same used to encrypt the string. Often times passwords and query strings are encrypted so that even if they are visible to the user, without the encryption key used to encrypt the text, the original input value remains hidden. If the decrypt service is used to decrypt text, but is using the wrong encryption key, the service will throw an exception.
Decrypt Use Examples
Using Decrypt Service in User Authentication Process
This process is used to validate users to log them in. When Users enter their user Id and Password, we retrieve the same from the database. Passwords should always be stored in encrypted formats. In this example, we decrypt the password and match it the password field on webpage to validate the user.
Here’s a closer look at the inputs of Decrypt service. “Text” is the text we would like to decrypt. “Password” is the decryption key. Note that decryption key should match the one used while encrypting the text.
In the output logs we can see decrypted text.
Decrypt Service With Wrong Key
In this example we are encrypting “TEST” and trying to decrypt the same, but notice that while encrypting we haven’t used any encryption key and in the “Decrypt” service we are using “1234” as decryption key.
We get a decrypt exception if the key doesn’t match encryption key.