如何在ruby中使用md5字节数组?

时间:2017-03-03 12:56:54

标签: ruby node.js

NodeJS中的

>var md5 = require('md5')
>md5([1])
55a54008ad1ba589aa210d2629c1df41
Ruby中的

pry(main)> Digest::MD5.hexdigest [1]
TypeError: no implicit conversion of Array into String
from (pry):20:in `digest'

我正在尝试使用' Array#pack'将字节数组转换为big-endian 32位字:

pry(main)> Digest::MD5.hexdigest [1].pack('L*')
=> "4352d88a78aa39750bf70cd6f27bcaa5"

但是结果与nodejs不同,我不熟悉字节操作,请让我知道如何使用ruby来获得与nodejs相同的结果

1 个答案:

答案 0 :(得分:1)

<?php include ("includes/header.php");?>
<?php include_once ("includes/config.php");?>
<!--database start-->
<?php
   $test=mysql_query("SELECT * FROM siteler");
   $sayi=mysql_num_rows($test);
   $deneme=mysql_fetch_row($test);
?>
<div class='container'>
   <div class='row'>
      <?php
         while ($deneme=mysql_fetch_array($test)) {
            echo '<div class="col-md-3 col-sm-6 col-xs-12 back-colour">';
            echo '<p><img src="'.$deneme['site_pic'].'"></p>';
            echo '<p class="box-design">' .$deneme['site_name']. '</p>';
            echo '<p class="box-design">' .$deneme['site_ref']. '</p>';
            echo '<p class="box-design">' .$deneme['bet_turu']. '</p>';
            echo '</div>';
      }?>
   </div>
</div>
<!--database end-->