MSSQL SQL Cryptographic function Hashbytes Usage Introduction

Source: Internet
Author: User
Tags md5 encryption mssql sha1 sha1 encryption

Transferred from: http://www.maomao365.com/?p=4732

I. Introduction to MSSQL SQL Hashbytes function

The Hashbytes function functions as: Returns a character,
Return values after encryption via MD2, MD4, MD5, SHA, SHA1, sha2_256, sha2_512

Hashbytes (' parameter 1 ', ' parameter 2 ')

Parameter 1:
Input Encryption Type example: MD5
Parameter 2:
Enter the string to be encrypted (the maximum value of the encrypted string is 8000 bytes)
return value:
The maximum return value is 8000 bytes
Precautions:
When an exception is entered for the encryption type, NULL is returned

Second, MSSQL SQL Hashbytes example Application

Example 1:

   DECLARE @info nvarchar(4000); SET @info = CONVERT(nvarchar(4000),'www.maomao365.com'); SELECTHashbytes ('SHA1',@info);---Return with SHA1 encryptionSELECTHashbytes ('MD5',@info);---Return with MD5 encryptionSELECTHashbytes ('MD2',@info);---Return with MD2 encryption

Example 2:

     Create TableA (info1varchar( -))Insert  intoA (INFO1)Values('www.maomao365.com')Insert  intoA (INFO1)Values('cat and Cat Hut')Insert  intoA (INFO1)Values('MSSQL Tutorial Dedicated')Insert  intoA (INFO1)Values('Introduction to MSSQL function usage') SelectHashbytes ('Md5', INFO1) as [MD5 Encryption], Hashbytes ('SHA1', INFO1) as [SHA1 Encryption], Info1 fromAtruncate TableADrop TableA

MSSQL SQL Cryptographic function Hashbytes Usage Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.