Data is encrypted by using a secret code to scramble it so that only someone with that code can use it. It is a very old idea but modernised today to be much more secure, so that credit card information and passwords can be securely stored, and are safe even if the files storing them are stolen.
Data passing between your computer and a website can be encrypted in real time using 'SSL' - secure socket layer. Any website with a url starting https:// (not http://) uses SSL, and is used to encrypt payment data so it cannot be read if it is intercepted. Numbers called digital keys are used to encode the data. These numbers can be up to 2048 digits.
Encryption is sometimes necessary, but there are disadvantages
a) It makes website browsing slower, because each data packet has to be scrambled and unscrambled.
b) SSL secured websites have to pay for and use a digital certificate. This has to be renewed periodically.
Often only single pages, such as log in pages or payment pages are encrypted, but because of privacy concerns and Government spying, more and more websites are turning to encryption.
On your own computer, individual files or whole disks can be encrypted. This may be unwise. If you lose then encryption key, or the file containing it becomes corrupted, your data is lost