The content field in a NIP-04(DM) event is encrypted using AES-256-CBC. To create the key you combine the recipients public key and the senders private key to get a shared key.
You can read more about it here: https://github.com/nostr-protocol/nips/blob/master/04.md