PDA

View Full Version : سوال: کد کردن اطلاعات توسط توابع اسکیوال



baran_mehr
شنبه 04 دی 1389, 15:46 عصر
چطور میشه اطلاعات را توسط برنامه به اسکیوال فرستاد و با استفاده از تابعی اونها رو رمز کرد و تو جدول نگه داشت و یا موقع خواندن اطلاعات معکوس این کار را انجام دهد

Reza_Yarahmadi
شنبه 04 دی 1389, 18:27 عصر
رمز نگاری معمولا در سطح App انجام میشه تا در صورتیکه بین App و SQL Server کسی دسترسی به اطلاعات پیدا کرد نتونه ازشون استفاده کنه ولی اگر شما قصد دارید در SQL Server این کار رو انجام بدید نگاهی به مثال زیر بندازید.
مثالی از Books Online


USE AdventureWorks;
GO

-- Create a column in which to store the encrypted data.
ALTER TABLE HumanResources.Employee
ADD EncryptedNationalIDNumber varbinary(128);
GO

-- Open the symmetric key with which to encrypt the data.
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;

-- Encrypt the value in column NationalIDNumber with symmetric key
-- SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
UPDATE HumanResources.Employee
SET EncryptedNationalIDNumber
= EncryptByKey(Key_GUID('SSN_Key_01'), NationalIDNumber);
GO

-- First, open the symmetric key with which to decrypt the data.
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
GO

-- Now list the original ID, the encrypted ID, and the
-- decrypted ciphertext. If the decryption worked, the original
-- and the decrypted ID will match.
SELECT NationalIDNumber, EncryptedNationalID
AS 'Encrypted ID Number',
CONVERT(nvarchar, DecryptByKey(EncryptedNationalID))
AS 'Decrypted ID Number'
FROM HumanResources.Employee;
GO
فکر کنم واضح باشه ولی در صورتی که سوالی داشتید بپرسید تا توضیح بدم.

aghayex
شنبه 04 دی 1389, 21:19 عصر
من با آقا رضا موافقم چون ما اطلاعات رو کد میکنیم که اگه دیتابیس رو کسی دزدید از اطلاعاتش چیزی نفهمه یا الگریتم کد کردن رو بدست نیاره و این مستلزم این هست که ما این الگریتم رو در برنامه اسفاده کنیم نه در توابع اس کی ال