This is all covered in Law 18.10 "Crediting of runs scored":
Unless stated otherwise in any of the Laws,
18.10.1 if the ball is struck by the bat, all runs scored by the batting side shall be credited to the striker, except for the following:
- an award of 5 Penalty runs, which shall be scored as Penalty runs
- the one run penalty for a No ball, which shall be scored as a No balls extra.
18.10.2 if the ball is not struck by the bat, runs shall be scored as Penalty runs, Byes, Leg byes, No ball extras or Wides as the case may be. If Byes or Leg byes accrue from a No ball, only the one run penalty for No ball shall be scored as such, and the remainder as Byes or Leg byes as appropriate.
Strike rate is then just the number of runs credited to the batsman divided by the number of (valid) balls they faced, traditionally then multiplied by 100.