It can either be piles or anal fissure, as in both conditions pain and discomfort is felt only when passing hard stools, a lump is felt at anal opening along with occasional bleeding.
You need to get yourself diagnosed by a registered doctor for accurate treatment.
Next Steps
Meanwhile avoid getting constipated, eat healthy nutritious food rich in fibres, have plenty of water throughout the day, avoid spicy and fried food etc. If discomfort or pain is much at the moment, do sitz bath in Luke warm water twice a day for 15-20 minutes.