Encrypt Stored Procedure

  • I would like to encrypt SP, but I do not know how security different between

    1 general procedure with "WITH ENCRYPTION" : display on Object Explorer windows

    2 temp procedure with "WITH ENCRYPTION" : NOT display

    3 temp procedure without "WITH ENCRYPTION" : NOT display

    CREATE PROCEDURE EncryptSP

    WITH ENCRYPTION

    AS

    BEGIN

    ... Statement ...

    END

    CREATE PROCEDURE #EncryptSP

    WITH ENCRYPTION

    AS

    BEGIN

    ... Statement ...

    END

    CREATE PROCEDURE #EncryptSP

    AS

    BEGIN

    ... Statement ...

    END

    So, I have a question that

    1. Is it enough to encrypt with "WITH ENCRYPTION"?

    2. Does the temp procedure both encrypt and not encrypt, can decrypt by 3rd party tools?

  • It's not actually encryption, it's obfuscation. Give me a DB with encrypted procs, I'll give you back the decrypted versions in maybe 10 minutes, if that.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I see, so How can I encrypt the stored procedure?

  • You can't.

    You can encrypt the entire DB with TDE, that's protection against backups been stolen. Otherwise, secure the server, limit access to SQL and make sure you have your permissions set correctly.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • The bigger question is what do you hope to gain by encrypting the procedure code? I doubt you are doing anything so revolutionary that you need to protect how you manipulate the data. The sql is not really very important...now the data itself is another story.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • A plug for our sponsors:

    redgate SQL Prompt can optionally decrypt objects compiled WITH ENCRYPTION for you right within an SSMS Query window. Encrypted objects appear decrypted when you hover over then and click on the quickview to see the definition.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply