Some of the items mentioned in this survival article are important, but in the final analysis, when encountering a Shark, you cannot outrun them, but you can fight, punch and kick.
I am not speaking through experience with a Shark here, but I have experience with some vicious dogs, and fighting back has been a winner 99% of the time. When I could not scare them off and had to deal with one up close, grabbing it by the ear or getting to high ground worked….
Fight Back: When a shark wants to eat you, you’ll know in advance: It will hunch its back, lower its fins, and rush at you in a zigzag pattern. Thrust your spear gun, camera housing, dive knife, or anything else you’re packing to discourage it. If you have a surfboard or body board, use it as a shield. If you are swimming and completely unarmed, punch the shark’s supersensitive nose or stab at its eyes or gills. If the shark bites into you and begins to drag you underwater, don’t play dead or give up. Get aggressive and do some damage to the shark. It might just let go.