My question: How can one programmatically passphrase-protect a file? I know that we can do it with PGP and other cryptography software, but how does it actually work? I don't really care about what programming language or algorithm to use. I am just looking for commonly-used processes. (Do we SHA512 the passphrase and use that as part of an asymmetric key-pair and then encrypt our files that way? That kind of thing.)

What I have done to try and answer my question: Google results just tell me how to use openssl/pgp/etc/etc on the command line. Searching this forum has not turned up anything I am looking for. I am not interested in how to use openssl to do it. I'm interested in how to use something like libssl to do it.