Showing posts with label md5. Show all posts
Showing posts with label md5. Show all posts

Monday, March 26, 2012

MD5 in SQL

Is there any MD5() type of function SQL Server to encrypt
a string?
Thanks,
LixinNothing built in. Take a look at wiHash and wiCrypt from www.whamware.com.
Tom
"Lixin Fan" wrote:
> Is there any MD5() type of function SQL Server to encrypt
> a string?
> Thanks,
> Lixin|||Tom,
Thanks a lot.
Lixin
>--Original Message--
>Nothing built in. Take a look at wiHash and wiCrypt from
www.whamware.com.
>Tom
>"Lixin Fan" wrote:
>> Is there any MD5() type of function SQL Server to
encrypt
>> a string?
>> Thanks,
>> Lixin
>
>.
>

MD5 Hashing rows?

I'm trying to implement some sort of security checking against database
modification. I'm thinking to store a list with Hash values for row sets.
i.e.
[pseudocode]
byte[] returnHash = MD5Hash( SELECT stuff FROM database WHERE junk )
[/pseudocode]
Is there a way to do an MD5 hash or equivilent without outputting the result
to a file and just hashing the file?
Is there a better way how to achieve the same goal?
Any comments appreciated. Thanks for your time!
-EdgarsEdgars Klepers wrote:
> I'm trying to implement some sort of security checking against database
> modification. I'm thinking to store a list with Hash values for row sets
.
> i.e.
> [pseudocode]
> byte[] returnHash = MD5Hash( SELECT stuff FROM database WHERE junk )
> [/pseudocode]
> Is there a way to do an MD5 hash or equivilent without outputting the resu
lt
> to a file and just hashing the file?
> Is there a better way how to achieve the same goal?
> Any comments appreciated. Thanks for your time!
> -Edgars
In SQL Server 2005 you could use the HashBytes function.
In earlier versions I think you'll have to use the .NET crypto classes
or Microsoft's COM crypto API. That means client side code or a call to
external code from SQL Server. Maybe you could write an extended proc
to do it (would require C++).
SQL Server 2000 has the CHECKSUM / BINARY_CHECKSUM functions but these
are just simple checksums not strong hashes.
David Portas
SQL Server MVP
--|||If you're using SQL Server 2000, there is an extended stored procedure
for MD5 hashing (and it's quick)
http://www.codeproject.com/database/xp_md5.asp|||markc600@.hotmail.com wrote:
> If you're using SQL Server 2000, there is an extended stored procedure
> for MD5 hashing (and it's quick)
> http://www.codeproject.com/database/xp_md5.asp
That's . Thanks for the link.
David Portas
SQL Server MVP
--|||I did come across that. How would one put in an entire row, or more
importantly an entire row set into that function to hash?
"markc600@.hotmail.com" wrote:

> If you're using SQL Server 2000, there is an extended stored procedure
> for MD5 hashing (and it's quick)
> http://www.codeproject.com/database/xp_md5.asp
>|||David Portas (REMOVE_BEFORE_REPLYING_dportas@.acm.org) writes:
> In SQL Server 2005 you could use the HashBytes function.
Beware that in SQL 2005 RTM, HashBytes returns a random value if you pass it
a NULL value. SQL Server MVP Steve Kass has filed bug about it, and the
bug has been acknolweged as fixed, although it is unknown what result
hasbytes(NULL) yields after the fix.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Exactly how will depend upon your business requirements.
At the simplest level you can concatenate the relevant columns
select dbo.fn_md5( coalesce(colA,'') + coalesce(colB,'') )
from sometable
However, this may give you unexpected collisions in that if you have
a row with, for example, colA='X' and colB='YZ' and another row with
colA='XY' and colB='Z'. It also doesn't distinguish NULLs from empty
strings.
This may be acceptable to you though.
Also consider folding all character data to upper case and
removing leading/trailing spaces.
Lots of options, you decide.
Regards.

MD5 function ?

Hi,
I am quite new to T-SQL and I'm facing a problem: how can I insert a
MD5 hash from T-SQL in one field? Using MySQL all I had to do was to
call the md5 function, but in SQL Server I failed to find it. Does MD5
function exist in T-SQL ? How can I solve this problem?
Thanks in advance!
AndreiCandreic wrote:
> Hi,
> I am quite new to T-SQL and I'm facing a problem: how can I insert a
> MD5 hash from T-SQL in one field? Using MySQL all I had to do was to
> call the md5 function, but in SQL Server I failed to find it. Does MD5
> function exist in T-SQL ? How can I solve this problem?
> Thanks in advance!
> AndreiC
In SQL Server 2005:
INSERT INTO tbl (col)
SELECT HashBytes('MD5', 'foobar') ;
In SQL Server 2000 you'll have to create your own. .NET has classes for
encryption and hashing.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||You can exttended stored procedure for MD5 in SQL Server 2000.
You can find a example below url.
http://www.codeproject.com/database/xp_md5.asp
"andreic"?? ??? ??:

> Hi,
> I am quite new to T-SQL and I'm facing a problem: how can I insert a
> MD5 hash from T-SQL in one field? Using MySQL all I had to do was to
> call the md5 function, but in SQL Server I failed to find it. Does MD5
> function exist in T-SQL ? How can I solve this problem?
> Thanks in advance!
> AndreiC
>|||If this is a secured application, you might consider using SHA-style hashes,
since MD5 is not considered secure anymore. An SHA-256/384/512 hash
function is available at
http://www.sqlservercentral.com/col...oolkitpart4.asp
"andreic" <andrei.croitoriu@.gmail.com> wrote in message
news:1150048549.960214.268210@.i40g2000cwc.googlegroups.com...
> Hi,
> I am quite new to T-SQL and I'm facing a problem: how can I insert a
> MD5 hash from T-SQL in one field? Using MySQL all I had to do was to
> call the md5 function, but in SQL Server I failed to find it. Does MD5
> function exist in T-SQL ? How can I solve this problem?
> Thanks in advance!
> AndreiC
>