Are there any built-in mechanisms in NEAR for storing private messages, or does the contract need its own code for encrypting message contents?
does the contract need its own code for encrypting message contents?
Contract shouldn't be encrypting/decrypting messages, as everything executed on blockchain layer is visible to everyone.
However you can store already encrypted messages and do encryption/decryption client-side (i.e. in JS). Most convenient way to do this is use the same crypto library as used in nearlib: