It may help to spend some time thinking about the offense you've committed and trying to determine the effect it has had on others. Unless it may cause more harm or distress, consider admitting the wrong you've done to those you've harmed, speaking of your sincere sorrow or regret, and specifically asking for forgiveness — without making excuses.
But if this seems unwise because it may further harm or distress, don't do it — it's not about making yourself feel better by apologizing. You don't want to add salt to a painful wound. Also, keep in mind that you can't force someone to forgive you. They will need to move to forgiveness in their own time.
In any case, we have to be willing to forgive ourselves. Holding on to resentment against yourself can be just as toxic as holding on to resentment against someone else. Recognize that poor behavior or mistakes don't make you worthless or bad.
Accept the fact that you — like everyone else — aren't perfect. Accept yourself despite your faults. Admit your mistakes. Commit to treating others with compassion, empathy and respect. And again, talking with a spiritual leader, mental health provider or trusted friend or relative may be helpful.
Forgiveness of yourself or someone else, though not easy, can transform your life. Instead of dwelling on the injustice and revenge, instead of being angry and bitter, you can move toward a life of peace, compassion, mercy, joy and kindness.