BOSTON — For the second time in as many days, a computer hacker stood before a federal judge and apologized for one of the largest thefts of credit and debit card numbers ever.

“I have violated the sanctity of millions of individuals around the United States,” said Albert Gonzalez in pleading for lenience. “I’m guilty of the crimes I accept full responsibility for my actions.”

U.S. District Judge Douglas Woodlock sentenced Gonzalez to 20 years and a day in prison, concurrent with a 20-year term he received from a different judge Thursday in two related cases. That means the Miami man, a one-time federal informant, will not serve any significant additional prison time.

The case Friday involved the theft of credit card numbers from Scarborough, Maine-based Hannaford Bros. supermarket chain, 7-Eleven and Heartland Payment Systems, a New Jersey-based card payment processor.

From Dec. 7, 2007, to March 10, 2008, Gonzalez and other hackers stole credit and debit card numbers from people who shopped at Hannaford supermarkets. The company operates more than 200 stores under various names in New England, New York and Florida.

An estimated 4.2 million card numbers were exposed, and by the time Hannaford publicly announced the breach on March 17, 2008, about 1,800 fraudulent charges had been made.

Thursday’s sentence stemmed from two cases that were combined and involved major retailers including TJX Cos., BJ’s Wholesale Club, Barnes & Noble and OfficeMax.

Woodlock said Friday that he believes the sentence is sufficient to deliver a message of deterrence.

“You’re going to be in your mid-40s when you get out,” the judge said to Gonzalez, who is 28. “That’s a tremendous loss.”

Prosecutors said tens of millions of credit and debit cards numbers were stolen, costing the companies, banks and insurers nearly $200 million.

Gonzalez, who pleaded guilty, was also fined $25,000 by Woodlock and will be required to serve three years of supervised probation after his release from prison. Prosecutors had sought a 25-year sentence, while defense attorney Martin Weinberg asked that his client serve 15 years.

Gonzalez still faces a hearing in June on what restitution he might have to pay. Woodlock indicated that Heartland is the only defendant in the case before him that is seeking restitution.

Authorities said Gonzalez amassed $2.8 million, which he used to buy a Miami condo, a car, Rolex watches and a Tiffany ring for his girlfriend. They said Gonzalez and two foreign co-defendants would drive past retailers with a laptop computer, tapping into those with vulnerable wireless Internet signals.

They would then install “sniffer programs” that picked off credit and debit card numbers as they moved through a retailer’s computers before trying to sell the numbers overseas, authorities said.

Prosecutors have said the two co-defendants, identified in court documents as “Hacker 1” and “Hacker 2,” are fugitives.

Gonzalez was first arrested for hacking in 2003, but was not charged because he became an informant, helping the Secret Service find other hackers.

A report submitted by a defense psychiatrist said Gonzalez was addicted to the Internet and displayed behavior consistent with Asperger’s syndrome, a form of autism.