Black Lives Matter
People take part in a protest against police brutality and in support of Black Lives Matter in New York in July 2016 Eduardo Munoz/ Reuters

Representatives from an American university have been forced to apologise after an alleged hacker broke into its Twitter account and posted a slew of racist political messages. The tweets made references to US president Donald Trump and the Black Lives Matter movement.

Screenshots of the tweets, which started at roughly 10:30pm on 19 May (Friday), show the suspected hacker using the 'Make America Great Again' slogan popularised by Trump last year. "We don't need you immigrant thieves in our school we are better than this," read one update.

The hacker wrote in one tweet: "Trump has done nothing but great things for our country during his presidency and will fix all the wrong that [expletive] president did."

Another post added: "All that black lives matter [expletive] is unneeded and unnecessary in our community."

Speaking to CBS Boston, Salem State spokesperson Nicole Giambusso said the university was disappointed by the incident.

"We're appalled by the language that was used. It in no way represents Salem State University and our community here," she said in a statement.

Both the Salem University and the city's police department have issued updates via social media.

"We apologise but our account was hacked & none of the recent posts represent the viewpoints of Salem State. We are looking into this matter," university officials wrote on Twitter after the incident.

Salem state police noted: "The official Salem State University Twitter account has been hacked by unknown miscreant(s) and will be shut down forthwith."

On 20 May (Saturday), the university's graduation day, a more robust statement was released.

"We are appalled by the hateful nature of these tweets, which in no way represent the views of Salem State University," it read, adding: "We have notified our social media followers of this compromise and are working with IT to implement additional security safeguards.

"It is incredibly unfortunate that such a hateful incident occurred on the eve of our commencement, and we hope to move forward as a community and not let it detract attention from the incredible accomplishments of more than 1,400 students graduating today."

The offending tweets were live for roughly two hours, being deleted just after midnight. The identity – and motivaton – of the alleged hacker remains unknown.

Social media hacks are becoming more common as people and institutions fail to implement multi-factor authentication. Last year, a group known as 'OurMine' was on a cybercrime spree that compromised the accounts of Google CEO Sundar Pichai and Facebook's Mark Zuckerberg.