Magnetic lock box, uses magnets for the hinge and for a keyed lock. There are two versions, the locking box requires a ferromagnetic filament to work (like ProtoPasta's Magnetic Iron Filament*), the non-locking box works with regular filaments. I don't actually have a use for this, but I've been wondering for years if this would work.
Hinge - The hinge uses 4mm cylinder magnets as the center of the hinge. By reversing the direction of each magnet (north to north, south to south), you can form a spring that works as the axis of the hinge. You can see the 4mm x 10mm cylinder magnets* inside the hinge in one of the pictures above (shorter magnets will work too, but more of them will be needed). In the magnetic iron box, the hinge can be made with only two magnets since they will attach to the side of the box, but it's more secure when more are used as described above.
Lock - The lock uses 3 - 4x4mm cylinder magnets*. They are normally recessed in the lid, but when the box is closed and the key is placed over the lock in the lock position, the magnets get pulled to the edge of the box, locking the lid in place, even after the key is removed. Holding the key in the open position against the box will push the magnets into the lid and open the box slightly (or press on the back of the lid to open). You can use different combinations of polarity to customize the lock and key.
Key - The key uses 6 - 4x4mm cylinder magnets* (each of the three slots takes two magnets). The magnets should be inserted in the key to match the polarity of the lock in the lock position and may need to be glued in place.
Customizing - The design is available in Onshape so if you want to change the size of the box, the types of magnets used, etc. you can do so there.