A fast hash such as SHA-256 can fingerprint a file or message. Given the same bytes, it produces the same digest. That makes it useful for integrity checks, but it is a poor way to store passwords because attackers can test guesses quickly.
Password storage requires a purpose-built, salted, tunable scheme such as Argon2id, scrypt, or bcrypt, with parameters chosen for the environment. A salt prevents identical passwords from producing identical stored results; the work factor slows guessing. Do not design a login system around a general hash generator, and never post real credentials as examples.
Neither kind of hash encrypts data.