If you are talking about encrypting T-SQL code like Stored Procedures and User Defined Functions, you can use
WITH ENCRYPTION
option while creating them.
CREATE PROCEDURE Procedure1
(
@Param1 int
)
WITH ENCRYPTION
AS
BEGIN
......
END
However, note that doing this is a one way ticket and there is no way to get back the source unless you save the source to a file for your reference. Doing a generate script on the procedure will not yield the source.