RICHMOND, Va. (AP) — A former Virginia high school teacher was sentenced Friday to nearly three years in prison for hacking into private digital accounts of celebrities and others.

Christopher Brannan was the fifth person charged in the 2014 “celebgate” scandal in which hackers obtained nude photographs and other private information from more than 200 people. Actresses Jennifer Lawrence and Mary Elizabeth Winstead are among the celebrities who’ve said they were victims.

Prosecutors alleged in court documents that Brannan hacked email accounts by answering security questions he could easily research by reviewing victims’ Facebook accounts. They said he also gained access to private accounts by using phishing email accounts designed to look like security accounts from Apple. Brannan then accessed the victim’s email accounts and searched for personal information, including nude photographs.

Brannan, 31, pleaded guilty in October to aggravated identity theft and unauthorized access to a protected computer.

ADVERTISEMENT

He apologized Friday before being sentenced to 34 months in prison. Brannan said he suffered from anxiety and depression, and became addicted to pornography.

“I let addiction take control of me and I deeply regret that,” he said.

Brannan was a special education teacher at Lee-Davis High School in Mechanicsville from 2013 to 2015. Court documents say he admitted hacking or trying to hack accounts of current and former teachers and students at the high school.

Under a plea agreement, both prosecutors and Brannan’s lawyer recommended the 34-month sentence.

Assistant U.S. Attorney Jessica Aber told U.S. District Judge Henry Hudson that the volume of intrusions was enormous.

“It’s truly an immense invasion of privacy,” she said.

Brannan’s lawyer, Abraham Del Rio III, told Hudson that Brannan coped with anxiety and depression by viewing online pornography.

After hearing from Del Rio, Hudson told Brannan he was still “a little bit perplexed” about why someone with a good job who seemed to be on a good path in life would hack into private accounts.

“These are questions that I’ve spent a lot of time asking myself,” Brannan said.

Brannan was ordered to begin serving his sentence April 1.