¿Hay un equivalente a SHA1 () en MS-SQL?


Convertir un par de procedimientos almacenados de MySQL a Microsoft SQL server. Todo va bien, excepto un procedimiento usado la función MySQL SHA1(). Parece que no puedo encontrar un equivalente a esto en MS-SQL.

¿Alguien conoce un equivalente válido para SHA1() en MS-SQL?

Author: GEOCHET, 2008-10-08

5 answers

SQL Server 2005 y posteriores tienen la función HashBytes().

 45
Author: Joel Coehoorn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-08 19:31:54

Si desea obtener un hash SHA1 exactamente como MySQL lo generaría (es decir, como un varchar), puede combinar HashBytes con sys.fn_varbintohexsubstring. Por ejemplo,

SELECT sys.fn_varbintohexsubstring(0, HashBytes('SHA1', 'password'), 1, 0)

Véase http://accessrichard.blogspot.co.nz/2010/12/sql-server-and-net-equivalent-to-php.html para más detalles.

 16
Author: Peter,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-31 01:44:03

De los grupos de Google - Una Posibilidad

 2
Author: LeppyR64,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-08 19:34:20

Es posible que también desee comprobar hacia fuera http://www.stev.org/post/2011/01/30/MS-SQL-SHASum-Support.aspx deberías poder modificarlo para producir lo que quieras. Aunque puede ser necesaria alguna codificación en c#.

 1
Author: James,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-02-07 13:02:19

No creo que haya soporte nativo, pero es posible que desee comprobar esto...

Http://blogs.msdn.com/sqlcat/archive/2005/09/16/469257.aspx

 0
Author: theraccoonbear,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-08 19:34:39