Let and be the two legs of the right triangle. Since the perimeter is 12 and the hypotenuse is 5, we know:

By the Pythagorean theorem, we also know:

I recommend squaring the first equation to find , since the second equation gives you the value of the sum of the squares of the legs.