Cockpit flight recorders are enclosed in a steel or titanium box (which is painted orange to make it easier to find). Inside that there are some racks of very rugged electronics, but most of these don’t actually need to withstand a plane crash, as long as the tapes or memory chips containing the actual data do.
They are stored in an inner armoured steel case coated in a flame retardant paint and lined with several layers of insulating materials. Blocks of paraffin wax are used at various points as thermal barriers. In a fire, the paraffin melts and absorbs some of the heat.