Let x represent the shorter leg. Then the Pythagorean theorem tells us
x^2 +(x +17)^2 = 25^2
2x^2 +34x +289 = 625
x^2 +17x -168 = 0
(x -7)(x +24) = 0 . . . . . the zero product rule tells you x=7 is the solution
The shorter leg is 7 cm; the longer one is 24 cm.