Yes.
You get a steady supply of explosives to feed into an expandable chamber. You then compress the chamber and light a match. The expanding wall of the chamber is connected via a connecting rod to a crank of some sorts, which converts the explosive force to a rotary motion. This rotary motion then spins a magnet encased in a coil, which will then produce your electricity.
Easy.
Automobile alternators do it all the time!
