For a truly scary view of nukes in space, look up the "Soviet Project K nuclear tests". Those did some MAJOR damage. :-(
Additionally, Starfish Prime was a two-stage thermonuclear weapon, with a yield of about 1.4 Megatons. However, the primary stage was about 15 Kilotons from a fission stage, which ignited a secondary fusion stage of slightly less than 1.4 Megatons. From an EMP perspective, though, it is believed that the EMP effect of the primary fusion stage may have "short circuited" the EMP effect from the fusion secondary stage, meaning that the damage caused on Earth by the test was equivalent to only about a 15 Kiloton weapon. Note that there are now single-stage weapons, with yields of up to about 500 Kilotons, which may have an effect over 30 times as strong as the Starfish Prime test. Many of these are of the Sloika, or layer-cake, design. It is indeterminate as to what the Soviet Project K nuclear test shots used.
As for nuclear power for spacecraft, there are two approaches to that. One uses a short half-life material, such as Plutonium-238, to produce thermal energy to power a Radioisotope Thermoelectric Generator (RTG). Quite a few spacecraft have safely used these. The other approach is to have an actual nuclear fission reactor aboard the spacecraft. Some of these haven't turned out so well, such as the Kosmos 954 craft, which radioactively contaminated a large area in northern Canada when it crashed (Beware the giant mutant lobsters!).