Implementing a crypto algorithm is hard. You should not attempt it unless you have significant experience and expertise in the field of cryptography. Even though you might come up with something that passes the published test cases, an inexperienced programmer may produce an implementation that is vulnerable attack through other channels, such as timing etc.
This essay from Bruce Schneier is an interesting read.
In short, find an existing implementation that is widely known, used and trusted. It will have had a lot of scrutinisation and testing and is much more likely to be secure than anything you could do yourself.