How to use the charenc.utf8.stringToBytes function in charenc

To help you get started, we’ve selected a few charenc 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 codeforgeek / RESTful-api-using-nodejs / node_modules / MD5 / md5.js View on Github external
md5 = function (message, options) {
    // Convert to byte array
    if (message.constructor == String)
      if (options && options.encoding === 'binary')
        message = bin.stringToBytes(message);
      else
        message = utf8.stringToBytes(message);
    else if (typeof Buffer != 'undefined' &&
        typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message))
      message = Array.prototype.slice.call(message, 0);
    else if (!Array.isArray(message))
      message = message.toString();
    // else, assume byte array already

    var m = crypt.bytesToWords(message),
        l = message.length * 8,
        a =  1732584193,
        b = -271733879,
        c = -1732584194,
        d =  271733878;

    // Swap endian
    for (var i = 0; i < m.length; i++) {
github JedWatson / react-select / examples / dist / app.js View on Github external
md5 = function (message, options) {
    // Convert to byte array
    if (message.constructor == String)
      if (options && options.encoding === 'binary')
        message = bin.stringToBytes(message);
      else
        message = utf8.stringToBytes(message);
    else if (isBuffer(message))
      message = Array.prototype.slice.call(message, 0);
    else if (!Array.isArray(message))
      message = message.toString();
    // else, assume byte array already

    var m = crypt.bytesToWords(message),
        l = message.length * 8,
        a =  1732584193,
        b = -271733879,
        c = -1732584194,
        d =  271733878;

    // Swap endian
    for (var i = 0; i < m.length; i++) {
      m[i] = ((m[i] <<  8) | (m[i] >>> 24)) & 0x00FF00FF |
github vightel / FloodMapsWorkshop / publisher / lib / sha1.js View on Github external
sha1 = function (message) {
    // Convert to byte array
    if (message.constructor == String)
      message = utf8.stringToBytes(message);
    else if (typeof Buffer !== 'undefined' && typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message))
      message = Array.prototype.slice.call(message, 0);
    else if (!Array.isArray(message))
      message = message.toString();

    // otherwise assume byte array

    var m  = crypt.bytesToWords(message),
        l  = message.length * 8,
        w  = [],
        H0 =  1732584193,
        H1 = -271733879,
        H2 = -1732584194,
        H3 =  271733878,
        H4 = -1009589776;
github pvorb / node-md5 / md5.js View on Github external
md5 = function (message, options) {
    // Convert to byte array
    if (message.constructor == String)
      if (options && options.encoding === 'binary')
        message = bin.stringToBytes(message);
      else
        message = utf8.stringToBytes(message);
    else if (isBuffer(message))
      message = Array.prototype.slice.call(message, 0);
    else if (!Array.isArray(message) && message.constructor !== Uint8Array)
      message = message.toString();
    // else, assume byte array already

    var m = crypt.bytesToWords(message),
        l = message.length * 8,
        a =  1732584193,
        b = -271733879,
        c = -1732584194,
        d =  271733878;

    // Swap endian
    for (var i = 0; i < m.length; i++) {
      m[i] = ((m[i] <<  8) | (m[i] >>> 24)) & 0x00FF00FF |
github pvorb / node-sha1 / sha1.js View on Github external
sha1 = function (message) {
    // Convert to byte array
    if (message.constructor == String)
      message = utf8.stringToBytes(message);
    else if (!Array.isArray(message))
      message = message.toString();
    // otherwise assume byte array

    var m  = crypt.bytesToWords(message),
        l  = message.length * 8,
        w  = [],
        H0 =  1732584193,
        H1 = -271733879,
        H2 = -1732584194,
        H3 =  271733878,
        H4 = -1009589776;

    // Padding
    m[l >> 5] |= 0x80 << (24 - l % 32);
    m[((l + 64 >>> 9) << 4) + 15] = l;
github petrosagg / papagal / src / vendor / MD5 / index.js View on Github external
var r = require("crypt"), o = require("charenc").utf8, i = require("charenc").bin, s = function(e, t) {
            if (e.constructor == String) {
                if (t && t.encoding === "binary") {
                    e = i.stringToBytes(e);
                } else {
                    e = o.stringToBytes(e);
                }
            } else {
                if (typeof n != "undefined" && typeof n.isBuffer == "function" && n.isBuffer(e)) {
                    e = Array.prototype.slice.call(e, 0);
                } else {
                    if (!Array.isArray(e)) {
                        e = e.toString()
                    };
                }
            }
            for (var a = r.bytesToWords(e), u = 8 * e.length, l = 1732584193, c = -271733879, p = -1732584194, d = 271733878, h = 0; h < a.length; h++) {
                a[h] = 16711935 & (a[h] << 8 | a[h] >>> 24) | 4278255360 & (a[h] << 24 | a[h] >>> 8);
            }
            a[u >>> 5] |= 128 << u % 32;
            a[(u + 64 >>> 9 << 4) + 14] = u;
            for (var f = s._ff, m = s._gg, g = s._hh, v = s._ii, h = 0; h < a.length; h += 16) {

charenc

character encoding utilities

BSD-3-Clause
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis