If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness (1John 1:9).
The apostle Peter was one of three disciples who walked with Jesus closer than the other nine. He was the most enthusiastic and the one man who was willing to step into territories where others would not dare. He was the first to step out of the boat and walk on water. He wanted to protect Jesus at times when Jesus rebuked him for having a demon influence him. He cut off the ear of the guard that wanted to arrest Jesus in the garden. Peter had lots of extreme emotions that were later harnessed by the Holy Spirit as he matured.
The greatest trial for Peter was when he denied the Lord just before Jesus was crucified. Three times he denied knowing Jesus. Jesus predicted that the cock would crow after the third time just to reinforce the prophecy to Peter. It literally crushed Peter when he realized he had failed His Lord so badly.
The Lord forgave Peter for his denial. However, gaining forgiveness from Jesus was not the most difficult part for Peter. The hard part was forgiving himself. As we mature in the faith, we begin moving in victory after victory with our Lord. Then, out of nowhere, an event happens that reveals our true sin nature, and we are confronted face-to-face with this reality. We cannot believe that we are capable of such sin. There is no good thing in us save the grace of Jesus Christ and His blood that cleanses us. When God looks at us, he looks at the blood of Christ that has covered our sin. He does not look at our sin once we confess it.
When we have difficulty forgiving ourselves, this is pride at its deepest level. We are making an assumption that we should never have sinned and that we are too mature to sin. This is a trap from the enemy of our souls. People who cannot forgive do not recognize from what they have been forgiven. That includes us.