Saturday 15 January 2011

javascript - Binary base64encode at CasperJS -


Is there any way of base 64 encoded binary data in CasperJS?
I mean something like this:

  var pdfFile = require ('fs'). Open ('some.pdf', 'br'); Var pdf = pdfFile.read (); Var Encoded = _some_func_for_encode (pdf);   

Thanks.

You can definitely use the native JS method Btoa () and etob ().

Here is a very basic phantomjs script:

  var fs = require ('fs'); Var is filed = fs.read ('theileile'); Var res = btoa (filed); Console.log (race); Phantom.exit ();   

Base 64 encoding / decoding is not very complicated and you can easily find JS function such as.

No comments:

Post a Comment