This totally works. Studied this in college chemistry, and then did it to my truck. I ended up with a 15-year old rust-free toyota pickup. That never happens.
Look up cathode/anode in a chemistry book for more info, then do as Civic Type Sev said. This is used in marine applications to keep iron engine blocks/heads from rusting from the salts in the air/water, and the parts are already available very inexpensively. Don't buy expensive electronic devices that require power, the Zinc block works just fine.