2013-06-25 88 views

回答

5

PhantomJs本身不支持MD5,但您可以使用phantom.injectJs轻松注入外部脚本代码。

你有只是在javascript中找到一个实现。 MD5非常流行,不难实现。所以有很多实现,例如crypto-jswbond/md5-js

一个非常基本的脚本中使用CryptoJS可能是

var system = require('system'); 

if (system.args.length != 2) { 
    console.log("Usage: phantomjs md5_test.js input"); 
} else { 
    if(phantom.injectJs('md5.js')) { 
     console.log(CryptoJS.MD5(system.args[1])); 
     phantom.exit(); 
    } 
} 
+0

谢谢,我明白了,phantomjs比不同的NodeJS其实,我真的没有注意到它。 –

+0

或:console.log(md5(system.args [1])); – user956584