• You are right, there are built in functions. I can't imagine why you would not use them, but the only sensible alternative is to use the Cryptography namespace in C#, and follow this:

    http://technet.microsoft.com/en-us/library/ms345136(v=sql.90).aspx

    to use CLR code inside SQL Server.