You rarely use encoding for integrity1. Encoding is used to transform some data in another format, usually because it is more suitable to the other system. For example, base64 is used because some systems may not react very well to some binary data. Encoding might only help you against transmission errors. (E.g. if the base64 data received contains an invalid character, you know something went wrong.)
Hash functions can be used for integrity to ensure that the data has not been tampered by an attacker. Keyed-hash message authentication code (HMAC) use a hash function, along with a key (known by the sender and receiver) to ensure that the data has been sent by the right person, thus performing authentication.
As you may see, encoding merely offers integrity and you not protect you against an attacker. Hash functions, if they are correctly used, can protect the integrity of the transmitted data against both transmission errors and attackers.
In the case of providing an username and a password to a website, basic authentication will encode your username and password with base64. This does not provide any security at all, because anyone can decrypt it. For example, we can easily recover the username/password used in the Wikipedia page about basic authentication:
# Encoding the username and password
$ echo -n "Aladdin:OpenSesame" | base64
# Retrieving the encoded username and password
$ echo -n "QWxhZGRpbjpPcGVuU2VzYW1l" | base64 -D
The username/password are not encoded for security reason, but to escape special character.
1 See Error detection and correction (Wikipedia)