Questions tagged [hashbytes]

A hashing function within the Microsoft Transact-SQL Database Engine.

A hashing function within the Microsoft Transact-SQL Database Engine which supports the following algorithms:

  • MD2
  • MD4
  • MD5
  • SHA
  • SHA1
  • SHA2_256
  • SHA2_512

Resources

62 questions
2
votes
1 answer

C# hash and sql server's hashbytel function, same implementation?

I want to has on both the c# level and the sql server 2012 level. How do I know if the SHA1 implementation will produce the same results? In sql server I am doing: HASHBYTES('SHA1', @data) I haven't written my c# function yet. I'm just worried if…
cool breeze
  • 4,461
  • 5
  • 38
  • 67
1
vote
0 answers

Does Hash value differs between On prem SQL and Azure SQL when we try to find hash of a same column with same value?

I tried to find a hash of a value in on prem SQL, it gave -0x7100C195B6C4050ADEC642295F50C0B8 but when I tried to execute the same hash for azure SQL am getting a different hash. my code is select *, cast(HASHBYTES('MD5',CONCAT('AU_DWH','2527',ID as…
jeffry
  • 11
  • 1
1
vote
0 answers

SQL Checksum_agg(Checksum(columns)) returns same value for different datasets

I have multiple tables in one database that I use to compare to an offline access database and see if this offline access database matches any of these predetermined tables. The tables are all identical in structure but contain different values;…
GlassCake
  • 11
  • 1
1
vote
1 answer

Generating a hash in PHP to match T-SQL HASHBYTES output

I need to generate a hash in PHP that matches the output from the HASHBYTES function in T-SQL. Here is the code that was originally used to generate the hash in T-SQL: declare @input varchar(15) = [this is the incoming value entered by the user] …
Matt Evans
  • 13
  • 2
1
vote
1 answer

Convert passwords created with PWDENCRYPT to HASHBYTES

We have been using PWDENCRYPT in our site to hash passwords - but want to change it to using HASHBYTES. Is it possible to make this conversion automatic? I know that it is not possible to decrypt those strings - but what have I to consider to make…
Michael Eriksen
  • 167
  • 1
  • 3
  • 13
1
vote
1 answer

Declare variable for HashBytes

I am following a simple example from this question: DECLARE @HASHBYTES VARBINARY(128) = hashbytes('sha2_256', 'secret') SELECT cast(N'' as xml).value('xs:base64Binary(sql:variable("@HASHBYTES"))', 'varchar(128)'); It returns a correct hashed value:…
Maya Rager
  • 25
  • 2
  • 11
1
vote
1 answer

Why The Query Against HashKey returns no records

I am working on a new sql table. The table has a column [varbinary(8000)], where we are storing hash of a certain text. Now, I am trying to retrieve the same record back by using a where clause against the hashkey, but that yields zero records. I…
Mac Ank
  • 51
  • 1
  • 6
1
vote
3 answers

How to scramble or hash values in SQL server?

I am in the process of creating demo data from data that contains Patient History Information (PHI). There are a few columns where I just want to generate a random value that stays consistent throughout the data. For example, there is a field like…
CandleWax
  • 2,159
  • 2
  • 28
  • 46
1
vote
1 answer

Inserting output of hashbytes() function into a table

I have a table called tbenc. Want to insert a value in the Name column which should be hash encrypted using hashbytes() T-SQL function. create table tbenc ( Id int not null identity, Name varchar(300) null, ) declare @var…
igelr
  • 1,491
  • 2
  • 10
  • 25
1
vote
3 answers

SQL Server HASHBYTES conversion inconsistency?

When I execute this hardcoded, I get the correct result: Declare @result nvarchar(32) Set @result = convert(varchar(32), hashbytes('MD5', '1' + 'One' + 'Two' + 'Three'), 2) select @result Result: 4173AB4C6EE66BC1FF7B7E5D44A872CA (correct) But…
humudu
  • 699
  • 1
  • 7
  • 13
1
vote
1 answer

property 'StoreGeneratedPattern' set to 'Computed' are not supported. Use 'Identity' pattern

I am using Entity Framework database First approach I have a table having composite primary key on ID(int ,identity increment), HashKey (binary) auto generated based on multiple columns using sql hashbytes. Following is EF Column Mapping ID…
Chandra Mohan
  • 729
  • 2
  • 10
  • 29
1
vote
1 answer

Hashbytes Computed column cannot be persisted because the column is non-deterministic

I am trying to hash the datetime column using HashBytes alter table dbo.Events add HashKey AS hashbytes('MD5', cast(convert(varchar(200), format(datestamp,'yyyy-MM-dd HH:mm:ss.ffffff')) as varbinary)) persisted but as it is non-deterministic, I…
Chandra Mohan
  • 729
  • 2
  • 10
  • 29
1
vote
1 answer

HashBytes with datetime2 field

I am creating a hash key using hashbytes on multiple columns to get performance gain which we are using right now in where clause. alter table dbo.Table1 add HashKey AS CAST(hashbytes('MD5', PID+PNumber+CONVERT([varchar] (50),[DateStamp])…
Chandra Mohan
  • 729
  • 2
  • 10
  • 29
1
vote
2 answers

Java PreparedStatement: Binding Parameter to HASHBYTES

Right now, I have the prepared statement below, which works: SELECT email, password FROM Professor WHERE email = ? AND password = HASHBYTES('SHA1','" + password + "') p.setString(1, email); But when I try to parameterize the value to be…
KarasuEXE
  • 13
  • 5
1
vote
2 answers

SQL Server: How to retrieve actual value of password encrypted using HASHBYTES

insert into Customer(AccountNo,Name,EmailId,MobileNo,[Password],Balance, CustomerKey,OTPPin,CreatedBy,CreatedOn) values(@AccountNumber,@Name,@EmailId, EncryptByPassPhrase(@PassPhrase, CONVERT(nvarchar,@MobileNo)), …
radha singh
  • 21
  • 1
  • 3
  • 10