How to transform 5V into 12V?
These are called boost convertors. They take a low dc voltage (such as 5V) and convert it to a higher dc voltage such as 12V. They use an inductor to store energy in one half cycle of a clock and in the other half cycle the energy stored in the inductor charges up a capacitor. The capacitor is naturally charged to a higher voltage than the input voltage because of the way the inductor and switching components are placed. Here is another article: -



You can actually build this with op-amps/555s/resistors/diodes and a decent MOSFET (n channel) and if you are not that bothered about super high effciency then a NPN can replace the MOSFET.

Personally I'd go to TI or linear technology and buy one because it'll outperform anything you are likely to make if you are a beginner.