Randolph had spent the last two seasons at Blues having joined from Motherwell in the summer of 2013.
The Republic of Ireland international stopper, who recently turned down the offer of new contract with Blues, will join the Hammers as a free agent on 1st July.
"My initial reaction to joining West Ham is excitement," he told the official West Ham website.
"It was a tough decision turning down Birmingham's offer of a new contract because of the second part of the season we had and the team we had built but I felt like I couldn't turn down the chance of joining a club like West Ham.
"Everybody wants to try and get to the top of their profession and I'm no different.
"I started at Charlton when I was 16 and left when I was 23..
"It has been a long journey to try get back to the Premier League and a great achievement to be able to do so. It is where players all around the world would like to be."