Bruce17/safe-compare ? reverse-engineered prompt

Reverse engineered prompt

Build me a small Node.js package that safely compares two strings in a way that helps prevent timing attacks.

I want it to work like a simple function I can import and call with two values, returning true only when they match and false when they do not. It should handle strings of different lengths without leaking useful timing differences, and it should be easy to use in normal Node apps. If there is a better built in option in newer Node versions, mention that too, but keep this package useful for string comparison as well.

Please include a few basic tests that show matching strings pass, different strings fail, and different length strings fail too. Keep the code clean and minimal, with a short README style example showing how to install it and use it. If you need to, look up the current Node docs online so the comparison method is done the right way.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab