How Electrolytic Gold Refining Works in Modern Labs

Modern labs transform dirty gold into 99.999% pure riches using nothing but salt water and electricity – but how is this even possible?