Re-use of code in an implementation of a publicly known algorithm -> $60 million in damages. This is not the kind of liability you will ever want to take on.
1. https://www.a10networks.com/news/a10-networks-receives-jury-...
That's not to say you can't incorporated what you learned into the new code, but it should be, morally and legally, new code.
You should avoid this kind of temptation by not taking code with you when you leave a job.
Absolutely don't do that.
The far end of that would be reusing bash scripts you developed as an IT guy for a now out of business drywall manufacturer for you new job as an IT guy for a manufacturer of 3D printers.
No one will notice. There is no one to care (out of business). And it's not worth a lawyers time.
I've found it is rarely an issue that even raises eyebrows these days; unless the company is a software company selling software as their primary business, they don't care what the license is as long as it solves their problems and won't give them legal hassle down the road. Most companies just need solutions running on their servers; they don't care how the solutions get there.
If something is clearly work-for-hire, and isn't Open Source, I wouldn't re-use it without explicit written permission. But, I can't remember the last time I did work that met that description.
If that company owns the work you did, then you have no rights to it.
If the company does not exist, it may be another story, but you should check to be sure, because if previous owners can claim rights, it could ruin any fruits the project bears for you.
Here's a hint: once you develop something once - you can do it 3x faster and 2x better the second time around - from scratch.
Remember that most of coding is 'figuring things out' - i.e. architecture, which apis to use, the requirements.
If you know exactly what you need to do and how to do it - you're 80% of the way there.
Just re-write it - it will be much better, and you save yourself any possible legal or moral issues.