Former pharmaceutical executive Martin Shkreli speaks to the media in front of U.S. District Court for the Eastern District of New York with members of his legal team after the jury issued a verdict, August 4, 2017 in the Brooklyn borough of New York City.

"Pharma bro" Martin Shkreli said, "I was a fool" and called himself "far from blameless" in an emotional jailhouse letter to a judge asking her to give him a light prison sentence for his crimes.

"I have learned a very painful lesson," Shkreli wrote Judge Kiyo Matsumoto, who is due to sentence him for securities fraud charges on March 9.

"I accept the fact that I made serious mistakes, but I still believe that I am a good person with much potential," he wrote in his letter from the Metropolitan Detention Center in Brooklyn, New York.

He has been locked up there since September, when Matsumoto revoked his release bond for what was just the latest in a series of social media stunts.

"The trial and the six months in a maximum security prison has been a frightening wake-up call," Shkreli wrote.

"I understand how I need to change."

He also vowed to be "more open and honest in my business dealings" in the future.

Read Martin Shkreli's full letter here.

Shkreli's letter was part of a large court filing by his lawyers, who are asking Matsumoto to sentence him to somewhere between only 12 and 18 months in prison. That is much less than the decades behind bars that could be recommended by federal sentencing guidelines.

Shkreli himself in his letter told the judge that if she gives him a relatively light term, "I will do my absolute best to use my skills and whatever talents I have been blessed with for the betterment of humanity."

The 34-year-old Shkreli was convicted in August of misleading hedge fund investors about the performance of his funds, which were losing lots of money when he was claiming they were doing very well.

Evidence at trial showed that he used assets of a drug company he founded, Retrophin, to repay the investors — and then some.

"Despite the jury's verdict, I maintain that I never intended to actually harm anyone," he wrote the judge in his letter.

But he acknowledged having dodged answering investors' questions, and also having given them answers that "were only correct if put in a certain context."

"I wanted to be more than I was," Shkreli wrote in trying to explain his conduct.

But he also said that he is now a more "self-confident and secure person," who is no longer "haunted" by the demons that were the root cause of his insecurity.

"Never again will I prevaricate or omit or mislead — intentionally or not," Shkreli wrote. "I take responsibility for the fact that I used to behave and communicate in his way."

"It was wrong. I was a fool. I should have known better," he wrote.

Shkreli said his heart was broken over the investors and colleagues who now regret having associated with him.

He also said he has "let down" the employees in companies in which he remains a majority owner.

Shkreli addressed his often-controversial personality in the letter.

That personality has been evident in online feuds Shkreli has waged, contemptuous face-pulling before a congressional committee, and the Facebook post that offered a $5,000 bounty for each strand of Hillary Clinton's hair that his online followers could provide him.

It was that bounty that led Matsumoto to jail Shkreli after initially allowing him to remain free pending his sentencing.

"I am an [irreverent] and free-wheeling individual, who has never been shy about speaking my mind," he wrote. 'Please understand that when I get into a public war of words with someone, my comments do not always reflect my true nature."

"I regret where my temper can take me when I get angry or betrayed."

He said he has "worked on this bad habit" while in jail.

Shkreli called being locked up "both the most frightening experience of my life but also an opportunity for me to see a side of the world seldom seen or discussed."

He said he has tried his best to have "a positive impact on many of the people I encounter here."

"If I have something to teach my fellow inmates, I implored them to listen and learn," he wrote. "I have comforted the forlorn and forgotten men facing long sentences, many are severely depressed and sadly, suicidal."

"I try my best to set a good example for these individuals too, knowing my fame and achievements were something they might know of."