博文

目前显示的是标签为“base64”的博文

base64 in Nodejs and Java

From :  https://www.hacksparrow.com/nodejs/base64-encoding-decoding-in-node-js.html let secretBase64 = Buffer.from(“ JavaScript ”).toString('base64'); // SmF2YVNjcmlwdA== var b = new Buffer('JavaScript'); // Buffer var s = b.toString('base64'); // SmF2YVNjcmlwdA== var b = new Buffer('SmF2YVNjcmlwdA==', 'base64') var s = b.toString(); // JavaScript // ------------------- var b = new Buffer('SmF2YVNjcmlwdA==', 'base64') var s = b.toString('hex'); // 4a617661536372697074 var b = new Buffer('4a617661536372697074', 'hex') var s = b.toString('utf8'); // JavaScript //---------------------- $node >require('crypto').randomBytes(64).toString('hex') f3a302c14cd2f57bc6972a0d599857dbde877fbf03b38dd592b9635bc7f30299c9d5dfe44e5abb615737cf40a45958c8283b5d1132c4e7e0d8e66610044be1f4 https://expressjs.com/en/api.html var fs = require('fs' ); // function to encode file data to base64 enc...

Reading files in JavaScript using the File APIs

Introduction From : http://www.html5rocks.com/en/tutorials/file/dndfiles/ HTML5 finally provides a standard way to interact with local files, via the File API specification. As example of its capabilities, the File API could be used to create a thumbnail preview of images as they're being sent to the server, or allow an app to save a file reference while the user is offline. Additionally, you could use client-side logic to verify an upload's mimetype matches its file extension or restrict the size of an upload. The spec provides several interfaces for accessing files from a 'local' filesystem: File - an individual file; provides readonly information such as name, file size, mimetype, and a reference to the file handle. FileList - an array-like sequence of File objects. (Think <input type="file" multiple> or dragging a directory of files from the desktop). Blob - Allows for slicing a file into byte ranges. When used in conju...

How to parse Google Maps direction api's “overview_polyline”

图片
How to parse Google Maps direction api's “overview_polyline” 1.In Javascript I use this function to decode Polyline ‌​s in my Node.JS program. – josebetomex // These functions decode a polyline pointstring. // The first is mine and simply links the second function to the form. function decode () {   var instring;   var outstring;   var points;     instring = document.getElementById("polylineDecoder").encodedPolylineIn.value;   instring = instring.replace(/\\\\/g, "\\");   points = decodeLine(instring);   outstring = "";   for(i=0; i < points.length; i++) {     outstring = outstring + points[i][0] + ", " + points[i][1] + "\n";   }   document.getElementById("polylineDecoder").decodedPolylineOut.value = outstring; } // This function is from Google's polyline utility. function decodeLine (encoded) {   var len = encoded.length;   var index = 0;   var array = [];   var lat = 0...