Encrypting Script Functions and Procedures in MSSQL


A doubt, I have some custom functions and procedures and I don't want my client (who has access to the bank) to keep messing with their script. Does anyone know any native MSSQL way to encrypt these codes?


If you need something you give the customer to be secret, you've already lost this game of cat and mouse. In fact you were already defeated before the game even started.

The article mentioned in the comments itself shows how trivial it is to decrypt functions and procedures encrypted with WITH_ENCRYPTION . And with write access to the bank, your customer can edit the logic at will. If he's not worried about keeping his logic, he doesn't even need to decrypt yours, just overwrite it with new logic without even reading the old one.

Someone might suggest that if you want to keep your database logic intact, you can keep queries in the application. In addition to being less performant than having functions and procedures in the database, there is no source code that cannot be decompiled , so we ended up going back to square one.

If you don't want your logic read or changed, the only way is to sell service rather than code. Keep the application and the database on a server that only you have access to. Any other solution you are offered is snake oil.

Scroll to Top