Turn off your Samsung device. Enter Download Mode (Odin Mode) by using the button combination for your device:
Magisk will create a new file named magisk_patched.tar (or similar) in your downloads folder. odin 3131 patched work
Download the specific stock firmware for your Samsung model (CSC/HOME_CSC) from reliable sources like SamMobile or Frija. Turn off your Samsung device