The following is an extract of a poem. This is the text we will be using as our example input for encrypting with a password.
Twisted and gnarled, these roots run deep into realms that open whilst I sleep;
designing a counterfeit system composed of intricately versed poem.
Next, we have the password in which we shall encrypt everything with.
MolliePosellIsLikeSoAmazingYouCantEvenLookWithoutYourHeadBlowingUp
Now, when we encrypt the plain text input with the password we get the following.
���K�5��r�Y�]�I������~9���DҢ
��_;|���d�1�(*KEZ�#+�u�\�����Es���]W���� �}����}���U�st��R��@�
Now, that was encrypted into a binary sequence of 0's and 1's, so when we try to display it in the browser it looks like garbage. The "de facto" method for sending it to other people is to Base64 encode it into readable characters. That way when a program tries to use it, without knowing how, the sequence won't get muddled up by mistake. It would be comepletely useless then! Here's the encrypted string Base64 encoded into a text string:
6/cQS7Q15tFy01myXRVJ/BSU7RK5fjmfv5pE0qINoeFfO3zQ/vpktDEaKCpLRVq2IyvIddlc/pAcjxBFc4nW0F1XB/MWhyAEfRzp9cB9H7ryVdFzdLi9Uh2mQLU8ZItQcQZ+7GYnHvbfe1tHQ+JDPbto9nzRB0mcHtd+gUyP2fD7eIX6UeXoKVr1fpV6C1EZJyIB8Cdil0SvdlMdeiAfeQ==
When we decrypt it we should get the original plain text. If the following is not the same it means we messed up somewhere!
Twisted and gnarled, these roots run deep into realms that open whilst I sleep;
designing a counterfeit system composed of intricately versed poem.
The following fake password will be used to decrypt it, as if someone got hold of the message but didn't know the password so they tried the first thing they thought of.
ThisKeyJustWillNotWorkBecauseThePlaintextWasEncryptedWithADifferentKey
What the eavesdropping person will come up with; garbage because they used the wrong key to decrypt it with.
*Actually this function returns false for some reason. Maybe if they correct key is not given this is what it does, but nothing in the documentation specifies this. Bad documentation if you ask me.*