SQL DES encryption algorithm

SQL DES encryption algorithm to control the length of a string encrypted, at present the encrypted string is too long,

The encryption method of how to modify a cryptographic storage process and a decryption stored procedure?

SQL encryption is as follows:

CREATE SYMMETRIC KEY key1 WITH ALGORITHM=DES
ENCRYPTION BY PASSWORD='abc$123'
GO

OPEN SYMMETRIC KEY key1
DECRYPTION BY PASSWORD='abc$123'

DECLARE @str NVARCHAR(100),@Encrypted VARBINARY(MAX)
SET @str=N'The string to be encrypted'
SELECT @Encrypted=ENCRYPTBYKEY(KEY_GUID('key1'),@str)
SELEcT ''=@Encrypted encryption decryption, ''=CAST(DECRYPTBYKEY(@Encrypted) AS NVARCHAR(100))
CLOSE SYMMETRIC KEY key1
GO
DROP SYMMETRIC KEY key1
GO

Started by Yale at November 17, 2016 - 11:52 PM

This is the principle of encryption algorithm: http://msdn.microsoft.com/en-us/library/ms345262.aspx
Clarification regarding DES algorithms:
, DESX was incorrectly named. Symmetric keys created with ALGORITHM = DESX actually use the TRIPLE DES cipher with a 192-bit key. The DESX algorithm is not provided. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
, Symmetric keys created with ALGORITHM = TRIPLE_DES_3KEY use TRIPLE DES with a 192-bit key.
, Symmetric keys created with ALGORITHM = TRIPLE_DES use TRIPLE DES with a 128-bit key.

A stored procedure code can refer to the,
CREATE PROC decryptaslogin1
WITH EXECUTE AS 'login1′
AS
OPEN SYMMETRIC KEY sensitive_data
DECRYPTION BY CERTIFICATE SSNCert;

SELECT Employee,
CONVERT(VARCHAR, DECRYPTBYKEY(ssn))
FROM employeessn;

CLOSE ALL SYMMETRIC KEYS;
GO

Posted by Marvin at November 27, 2016 - 12:02 AM

Use the following code, see if you fit your requirements?

select sys.fn_VarBinToHexStr(hashbytes('MD5', '123456'));
select sys.fn_VarBinToHexStr(hashbytes('SHA1', 'China Shanghai'));

select hashbytes('SHA1', '123456');
select hashbytes('MD5', '123456');

Posted by August at December 04, 2016 - 12:47 AM

Or, like the upstairs said the use of other cryptographic algorithms.

Posted by Marvin at December 17, 2016 - 1:10 AM

@hdhai9451, select sys.fn_VarBinToHexStr(hashbytes('SHA1', 'China Shanghai ')); how do I decryption, I must be decrypted. But the parameters in URl.

Posted by Yale at December 29, 2016 - 1:45 AM

The encrypted string generated by the DES algorithm, fixed length, can not seem to limit the length of the

Posted by Goddard at January 06, 2017 - 2:41 AM

The above two is behind the two is encryption decryption, and you said that the practice of difference.

Posted by Marvin at January 07, 2017 - 2:26 AM