If you share your source code with anyone, they can do whatever they want with it: read it, change it, delete lines from it (not from your code, but the copy you gave them). So yes, if your program contains some kind of security check, they can easily bypass it.
So, what can you do?
I think do not share your code is obvious, but sometimes not an option (e.g. you're creating a library or framework).
When you share your code, they can always bypass the security check. Unless it's done in a server-client relationship and they do not have access to the server code. More secure, if the server is running online, not even on their machine as I've mentioned before to your question about hacking, you can always get the Assembly code of any program, so if they can read Assembly, then can understand what the server does. That being said, there are programs designed to obfuscate the compiled code (that still can be disassembled) to be very confusing and super hard to read.
If you only want to hide some credentials from them, then you can put that password check in a separately compiled library (DLL in Windows) so they won't be able to simply read the password check logic (again, unless they know how to read Assembly).
Just for hiding the password can use online resources as well: a service, that checks if the password the user entered matches the one stored on the server (which shouldn't be stored by the way, just some kind of has of the password).
The bottom line is, if they know only high-level programming languages, you can hide your "secret" in compiled code. If they are true wizards, they can probably break online services too if they can crack the system somehow.
As one of my teachers said: security is a matter of how important a thing is for you and how much it is worth for others.
You can hide your personal computer behind a 10-character-long password and probably no hacker would be interested in trying to break it just to get your pictures of your cat if it would take a month. But if the said 10-character long password takes one month to break (I'm just making up the character length - time to break relationship, do some research how long should a password be) but grants them access to your company's bank account that has millions of dollar income a month, damn well they will spend that month cracking your password.
I think you get the point. :) If you want to trick your mates, hiding the password in a dynamic library is enough, but it won't protect you from hackers who really want to break into your system.
Also, if it's just for your mates, you can do something tricky / interesting, like not having a password equality check, but rather checking some property of your password. E.g. any password would satisfy the security check that is easy to check, but hard to computer or guess. For instance, a credential could be two numbers (a and b) where a2 + b2 = c2 and both a, b, and c are primes. I do not know if there are any such primes that satisfy the equation, but that's the beauty of it: if you know such a trio of numbers, it's easy to solve (authenticate), but if you do not, it's pretty hard to guess one. (Sure you can write a program that would test a series of numbers, but that takes time...)
I think I gave you more of a theoretic answer than a ready-to-use solution. I still hope this helps, even if it's not 100% what you were looking for.
Good luck!
Update 1
I think my example is wrong, as these are the Pythagorean Triples and I do not believe there's any such triple of primes that would satisfy this equation. Anyway, you can come up with your own rule.
Update 2
I was thinking and you could create a fairly simple code that checks a password without exposing the password in the code.
The below code stores the (MD5) hash of your password, instead of the actual password. From the hash, they cannot guess your password, but the correct password always produces the same hash. The below passwordHexDigest was created to the super secret "My secret password". If you want to replace the hash (passwordHexDigest) with your own, You can just print hashlib.md5(password.encode()).hexdigest() of your own password (same piece of code that is used in the if statement).
import hashlib
passwordHexDigest = "0bf1334ac2aa41ae8de0f705188c1850"
password = input("Enter your password: ")
if passwordHexDigest == hashlib.md5(password.encode()).hexdigest():
print("CORRECT!")
else:
print("WRONG!")
Remember, a hash is not guaranteed to be unique. There is a small chance for hash collision, i.e. other inputs could produce the same hash. However, this chance is pretty low so you can take this as an acceptable risk in most applications.
Enjoy!