Authentication header

I am new to asterisk. I need to know how do I create the “response” for authentication of sip. I tried doing it the following way, but it didnt work:

Response = Hash("{0},{1},{2}",username,realm,secret)

Am i doing something wrong? Please, response …

Thanks in advance.