Usually when you deal with passwords people store their hash values, not the passwords in a plain text. Then when you check if password is correct, you just compare the hash values of password written by the user against that in the database/file you store. In matlab you can get MD5 or SH1 hash of a string using its embedded java.
for example:
md = java.security.MessageDigest.getInstance('MD5');
md5 = md.digest(uint8('my_secret_password'))'
% gives: 126 -28 22 -43 39 -94 -48 71 117 28 2 109 -126 -37 -66 -17
md = java.security.MessageDigest.getInstance('SHA1');
md5 = md.digest(uint8('my_secret_password'))'
% gives: 51 -91 -61 39 0 56 -19 -61 112 -10 9 -71 -111 117 117 -71 52 46 50 -122