Even if your algorithm is in the open, each user keeps a secret: the password (or other secret that is used as key to en- and decryption). You want that the algorithm works safe, even if it is known. Because it is always possible through decompiling to get the algorithm.
Why is the algorithm safe even if it is known? Because it works with mathematics, that need to much time decrypting it without the personal secret it was encrypted with. How that works in detail is out of the scope here, you should ask that on crypto.se or security.se.
So having the implementation (and thus the algorithm) out in the open is no downside. But it is even an upside. Many algorithms people came up with over time are flawed or easy to break with current technology (Cesar-cipher for example). If you use that even closed source, it is easy to detect it and break it. Even more: if you use a well-known and good algorithm, there are many points at which you can fail at implementation and make the whole software unsecure. Look at the details of the Debian-OpenSSL-bug for an example. So, having your code in the open allows experts to analyze it, and they usually make it public if they find bugs in the implementation. If they can't access the code, they cannot do that. So I would trust an Open-Source crypto that has no known bugs or is broadly criticized more than an Closed source program that might or might not have a good implementation. Naturally you should avoid both open source and closed source crypto with known problems.