Tema: Reto SHA1
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/01/2006, 05:46
jaimejaime
 
Fecha de Ingreso: enero-2006
Mensajes: 1
Antigüedad: 18 años, 3 meses
Puntos: 0
Reto SHA1

Quien sería capaz de convertir este código a ASP??? Un saludo!!

Código PHP:
   function hmacsha1($key,$data
   {
        
$blocksize=64;
        
$hashfunc='sha1';
        if (
strlen($key)>$blocksize$key=pack('H*'$hashfunc($key));
        
        
$key=str_pad($key,$blocksize,chr(0x00));
        
$ipad=str_repeat(chr(0x36),$blocksize);
        
$opad=str_repeat(chr(0x5c),$blocksize);
        
$hmac pack(
               
'H*',$hashfunc(
                   (
$key^$opad).pack(
                       
'H*',$hashfunc(
                           (
$key^$ipad).$data
                       
)
                   )
               )
           );
        return 
bin2hex($hmac);
    }
    
    function 
stringHexaToBytes($st)
    {
        
$res="";
        for (
$i=0;$istrlen($st);$i+=2)
        {
           
$c=substr($st,$i,2);
           
$res.=pack("H*",$c);
        }
        return(
$res);
    }