Understanding the algorithms and mathematics behind digital cryptography is important to using it effectively. However, you should not write the algorithms yourself. Not only is that an unnecessary use of your time, it is also potentially dangerous. You run the risk of exposing encryption keys to malicious processes, revealing information through the amount of time your code takes to run, or accidentally creating some other form of vulnerability. Security code should undergo a rigorous peer review process.
Always rely upon a tool that has undergone such a peer review. These include: