Including a 3rd party library in WordPress which needs to be accessible by wp-config

1st, the key should be generated once, not per request. The tutorial is suggesting you generate it via the library (probably via cli, or one off script you run in the browser) and then simple add:

define('JOSH_ENCRYPT_KEY', 'the-random-key-you-generated-gets-copy-pasted-in-here-manually');

into your wp-config.php file, so you dont need the lib to be in scope at that point.

If you are doing this in a plugin, you can define the constant within the plugin instead of in the wp-config.php file if you prefer.

However, i think the tutorial has a major flaw, in that the wordpress options api handles non string values (objects, arrays etc), whilst the wrapper provided does not