It's simple electrolysis. Just put an electrical current through some water and hydrogen will form at the negative electrode and oxygen will form at the positive electrode. The electrical current provides the energy needed to break the hydrogen-oxygen bonds and also provides the electrons needed for those atoms to bond with themselves, thus forming hydrogen and oxygen gas. This process, however, proceeds fairly slowly unless a salt is added to the water to increase its conductivity. However, adding sodium chloride causes some chlorine gas to form with the oxygen and some sodium hydroxide to form in the solution.