Bitcoin uses a technology called public/private key cryptography. Public/private keys allow a person to pay for something in Bitcoin without ever needing to provide the secret numbers that allow access to the account. This means since the secret access numbers (private key) are never provided, the purchaser is not vulnerable to having their money stolen when making a purchase.
This video explains the basics of using public/private key cryptography to create digital signatures: