How to use the binary.ByteString.wrap function in binary

To help you get started, we’ve selected a few binary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ringo / ringojs / modules / core / string.js View on Github external
value: function(algorithm) {
        var {ByteString} = require('binary');
        var md = java.security.MessageDigest.getInstance(algorithm || 'MD5');
        var b = ByteString.wrap(md.digest(this.toByteString()));
        var buf = [];

        for (var i = 0; i < b.length; i++) {
            var j = b[i];
            if (j < 16) {
                buf[buf.length] = '0';
            }
            buf[buf.length] = j.toString(16);
        }
        return buf.join('');
    }, writable: true
});
github gmosx / appengine / lib / google / appengine / api / urlfetch.js View on Github external
var parseResponse = function (response) {
    var b = new ByteString.wrap(response.getContent());
     
    var headers = {};
    for (var h in Iterator(response.getHeaders())) {
        headers[String(h.getName())] = String(h.getValue());
    }    
     
    return {
        content: b,
        finalUrl: String(response.getFinalUrl()),
        statusCode: response.getResponseCode(),
        headers: headers
    }
}
github ringo / ringojs / modules / io.js View on Github external
stream.read = function(maxBytes) {
        checkClosed();
        var result;
        if (isFinite(maxBytes)) {
            if (maxBytes < 0) {
                throw new Error("read(): argument must not be negative");
            }
            var end = Math.min(position + maxBytes, length);
            result = ByteString.wrap(buffer.slice(position, end));
            position = end;
            return result;
        } else {
            result = ByteString.wrap(buffer.slice(position, length));
            position = length;
        }
        return result;
    };
github ringo / stick / lib / middleware / etag.js View on Github external
function digest(body) {
        const md = java.security.MessageDigest.getInstance("MD5");
        body.forEach(function(part) {
            md.update(part);
        });
        return strings.b16encode(ByteString.wrap(md.digest()));
    }
github geosolutions-it / MapStore / externals / ringojs / modules / io.js View on Github external
stream.read = function(num) {
        checkClosed();
        var result;
        if (isFinite(num)) {
            if (num < 0) {
                throw new Error("read(): argument must not be negative");
            }
            var end = Math.min(position + num, length);
            result = ByteString.wrap(buffer.slice(position, end));
            position = end;
            return result;
        } else {
            result = ByteString.wrap(buffer.slice(position, length));
            position = length;
        }
        return result;
    };