We present an algorithm to compute H-2(G, U) for a finite group G and finite abelian group U (trivial G-module). The algorithm returns a generating set for the second cohomology group in terms of representative a-cocycles, which are given explicitly. This information may be used to find presentations for corresponding central extensions of U by G. An application of the algorithm to the construction of relative (4t, 2, 4t, 2t)-difference sets is given.