Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Towards the innovative SQL ideas
Browse by Tags · View All
ms sql server 119
ms sql 118
sql server 116
sql 115
database 102
tsql 81
#SQL Server 78
t-sql 75
#sql 71
sql server general 67

Archive · View All
April 2011 14
July 2011 12
May 2011 12
August 2011 11
June 2011 10
September 2011 8
December 2011 6
November 2011 6
June 2013 5
April 2013 5

Stored Procedure Encryption in SQL Server

Aug 15 2011 12:00AM by Paresh Prajapati   

Because of some security policies we need to require our code to be safe from Users who are going to use SQL Server database and objects of them and some outside threat. We have different different users to access the database objects or used for application.

We have so many ways to encrypt data, but here i am talkig about the code encryption. With this encryption security, Users can execute the stored procedures but can not view the code.

Let us check the how the Stored Procedures can be encrypted.
-- Creating demo objects

USE demo
GO

-- Creating table
IF (OBJECT_ID('UserMaster','U')> 0)
DROP TABLE UserMaster
GO

CREATE TABLE UserMaster
(
UserId INT,
UserName VARCHAR(100),
UserPwd NVARCHAR(100)
)

GO

-- Inserting demo records
INSERT INTO UserMaster
SELECT '1','User1','pwd1'
UNION ALL
SELECT '2','User2','pwd2'
UNION ALL
SELECT '3','User3','pwd3'

GO
Now we will create two Stored Procedures with and without encryption.
-- Creating Stored Procedure without encryption
CREATE PROCEDURE GetUserDataWithoutEncrypt
AS
BEGIN
SET NOCOUNT ON 

SELECT 
UserId,
UserName,
UserPwd
FROM UserMaster

END
GO


-- Creating Stored Procedure with encryption
CREATE PROCEDURE GetUserDataWithEncrypt
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON 

SELECT 
UserId,
UserName,
UserPwd
FROM UserMaster

END
GO
Executing both above created stored procedures , and you ca see there as both giving same output while users run them.
EXEC GetUserDataWithoutEncrypt
EXEC GetUserDataWithEncrypt
GO


Finally we will check the text of these both stored procedures objects.

-- Viewing text of Stored Procedure without Encrypted
EXEC SP_HELPTEXT GetUserDataWithoutEncrypt



-- Viewing text of Stored Procedure with Encrypted
EXEC SP_HELPTEXT GetUserDataWithEncrypt



Doing same thing for Encrypted Stored Procedure from UI and see what happen, 





It is not showing text in sys.syscomments as well.
SELECT 
* 
FROM sys.syscomments
WHERE id = object_id('GetUserDataWithEncrypt')
GO



Let me what you think for the stored procedure encryption and share your comment if you have used it.

Tags: sql, sql server 2008, sql server 2005, tsql, sql server, ms sql, ms sql server, sql server denali, #SQL Server, mssql, #sql, sql server 2011, database, sql server general, SQL Scripts, encryption,


Paresh Prajapati
6 · 22% · 7044
9
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

8  Comments  

  • Very interesting write up Paresh. Wonderful.

    When SP are encrypted Actual Execution Plan of the SP is also not visible - http://wp.me/p2NUQ-np

    Nice write up.

    commented on Aug 16 2011 12:18AM
    Pinal Dave
    146 · 1% · 326
  • How to decrypt the encrypeted stored procedure? is it possible?

    Regards Rajesh.M

    commented on Aug 16 2011 5:46AM
    mrajesh
    649 · 0% · 51
  • Thanks Pinal,

    I have seen the post which you attached, We can not see actual execution plan as well. Thank you again for sharing.

    commented on Aug 17 2011 4:38AM
    Paresh Prajapati
    6 · 22% · 7044
  • Hello Rajesh.

    We can not decrypt the text of that SP. If you have whole stored procedure text as backup then you can alter it with some change with new text.

    commented on Aug 17 2011 4:40AM
    Paresh Prajapati
    6 · 22% · 7044
  • Hello Rajesh,

    It is not a real encryption, only an obfuscatation which is not complicated to decrypt.See : link text

    http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/7dce7436-371b-441d-8f88-9e8832f8c616

    commented on Aug 17 2011 11:38AM
    Patrick Lambin
    161 · 1% · 296
  • Thanks Patrick for sharing nice links.

    commented on Aug 29 2011 12:26PM
    Hardik Doshi
    20 · 9% · 2839
  • see below link for decrypt stored procedure.

    http://optillect-sql-decryptor.software.informer.com/2.0/

    commented on Mar 27 2012 8:30AM
    Alpesh Gorasia
    128 · 1% · 392

Your Comment


Sign Up or Login to post a comment.

"Stored Procedure Encryption in SQL Server" rated 5 out of 5 by 9 readers
Stored Procedure Encryption in SQL Server , 5.0 out of 5 based on 9 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]