Online transactions are secure because of the use of cryptography. There are two types of cryptography that are used for online transactions: public-key encryption and symmetric-key encryption. Public-key encryption is used to encrypt data and send it to a receiver. The receiver then decrypts the data using a private key. Symmetric-key encryption is used to encrypt data and send it to a receiver, but both parties have the same key to decrypt the data.