Here are multiple methods for random loot (stats are not random, only which items you get are). This can be used for items, weapon, armor, etc., and you don't need to only use treasure chests -- maybe an NPC will give you some loot?
This tutorial was a request! Let me know what else you'd like to see, in the comments.