I came to this post after searching for a simple method to make a two-way hash encryption, based on max's answer, I wrote a simple ts class to provide what I need for my project, this is the ts class I saved it on the gist EncryptLib.ts,
I use it as the following:
import EncryptLib from './EncryptLib'
// example of app key using randomBytes(32)
const appkey = crypto.randomBytes(32).toString('hex')
// instantiate the class
const encryptLib = new EncryptLib()
// create a hash for my-secret-string
const encrypted = encryptLib.encrypt("my-secret-string", appkey)
// sample results: 47952829ab7cc1c6e0aa82fcdcc4aea5:f14d2daf18c8da4c5ccc56e99933d338
// [ivhex:hexstring]
// get my string back
const decrypted = encryptLib.decrypt(encrypted, appkey)