After installing Xampp (PHP v8.1.x) on Windows, you may face the issues related to sodium extension with Magento 2.4.5 or Magento 2.4.6, the error is like:
main.CRITICAL: Error: Undefined constant "Magento\Framework\Encryption\Adapter\SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES"
it's because sodium extension is not loaded.
How to fix this issue
1. Go to php.ini file, find "extension=sodium" then uncomment it by removing the semicolon (;)
2. Copy libsodium.dll file in xampp/php/ then put it to xampp/apache/bin/
3. Restart Apache
Check Results
You need to run phpinfo() to check the results. Find the table of sodium support, you will see the table like below screenshot