How to use md5 - 10 common examples

To help you get started, we’ve selected a few md5 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 staticdeploy / staticdeploy / storage / src / BundlesClient.ts View on Github external
Body: assetContent,
                    Key: this.getAssetS3Key(id, asset.path)
                })
                .promise();
        });

        // Remove the temporary unpacking directory
        await remove(unpackingDirPath);

        // Create the bundle database object
        const bundle = await this.Bundle.create({
            id: id,
            name: partial.name,
            tag: partial.tag,
            description: partial.description,
            hash: md5(partial.content),
            assets: assets,
            fallbackAssetPath: partial.fallbackAssetPath,
            fallbackStatusCode: partial.fallbackStatusCode
        });

        return toPojo(bundle);
    }
github YaoZeyuan / zhihuhelp_with_node / src / command / generate / base.ts View on Github external
getImgName(src: string) {
    // 直接将路径信息md5
    let filename = ''
    try {
      let srcMd5 = md5(src)
      let urlObj = new url.URL(src)
      let pathname = urlObj.pathname
      if (path.extname(pathname) === '') {
        // 避免没有后缀名
        pathname = `${pathname}.jpg`
      }
      if (pathname.length > 50) {
        // 文件名不能过长, 否则用户无法直接删除该文件
        pathname = pathname.substr(pathname.length - 50, 50)
      }
      filename = StringUtil.encodeFilename(`${srcMd5}_${pathname}`)
    } catch (e) {
      // 非url, 不需要进行处理, 返回空即可
      logger.warn(`[警告]传入值src:${src}不是合法url, 将返回空filename`)
    }
    return filename
github dcos / dcos-ui / plugins / tracking / actions / Actions.js View on Github external
start() {
    this.createdAt = Date.now();
    this.lastLogDate = this.createdAt;
    this.stintID = md5(`session_${this.createdAt}`);

    hashHistory.listen(
      Util.debounce(location => {
        Actions.setActivePage(location.pathname + location.search);
      }, 200)
    );

    // Poll to deplete queue
    const checkAnalyticsReady = () => {
      setTimeout(() => {
        if (!this.canLog()) {
          checkAnalyticsReady();
        } else {
          this.drainQueue();
        }
      }, 200);
github vpdb / server / server / modules / asset.js View on Github external
if (p && fs.existsSync(p)) {

		// browser caching
		var fd = fs.openSync(p, 'r');
		var modified = new Date(fs.fstatSync(fd).mtime);
		fs.closeSync(fd);
		var ifmodifiedsince = new Date(context.req.headers['if-modified-since']);
		if (modified.getTime() >= ifmodifiedsince.getTime() && !disableCache) {
			context.res.writeHead(304);
			context.res.end();
			return;
		}

		// file caching
		var hash = md5.digest_s(type + ':' + ':' + key + ':' + size);
		var filename = writeable.imgCache + '/' + hash + '.png';
		if (fs.existsSync(filename)) {
			//logger.info('[asset] File cache hit, returning ' + filename);
			return file(context, filename);
		} else {
			logger.info('[asset] No cache hit for ' + filename);
		}

		// cache, process.
		var now = new Date().getTime();
		processFct(gm(p), function(gm) {

			// stream to client
			gm.stream(function(err, stream) {
				if (err) {
					logger.error('[asset] ERROR streaming image: ' + err);
github 1956-studio / wechat-ship / server / core / api.js View on Github external
function hashData (url, datastr) {
	url = url.toLowerCase().substr(7);
	var indexS = url.indexOf("/");
	if(indexS == -1 || url.substr(indexS + 1) == "" ) {	// url is like http://127.0.0.1 or http://127.0.0.1/
		url = "host";
	}else {
		url = url.substr(indexS + 1);
	}
	return url+ "/" + md5.digest_s(datastr);
}
github dougbtv / bowline / library / User.js View on Github external
User.findOne({ _id: mongoose.Types.ObjectId(userid) },function(err,user){

			if (!err && user) {

				// this is required.
				if (inprofile.gravatar_email) {

					user.profile.gravatar_email = inprofile.gravatar_email;
					user.profile.gravatar_hash = md5.digest_s(inprofile.gravatar_email);
					user.profile.twitter_user = inprofile.twitter_user;
					user.profile.github_user = inprofile.github_user;
					user.profile.website = inprofile.website;

					user.save(function(err){
						if (err) {
							log.error('user_setprofile_sav',{userid: userid, err: err});
						}
						callback(err);
					});


				} else {

					callback("gravatar email is required, if you don't have a gravatar account, that's OK. just enter anything.");
github mozillaarchive / deuxdrop / clients / server.js View on Github external
response.on('end', function () {
            if (responseData) {
              responseData = JSON.parse(responseData);

              if (responseData.status === 'failure') {
                sendSignInComplete(data, client, null);
              } else {
                id = responseData.email;
                pic = 'http://www.gravatar.com/avatar/' +
                      md5.hex_md5(id.trim().toLowerCase());

                // Store the user data for next request.
                redis.set('browserid-assertion-' + assertion, id);

                //Add the user ID to the list of users.
                redis.sadd('users', id);

                //Add the user to the store
                redis.hmset(id, 'id', id, 'name', id, 'pic', pic);

                sendSignInComplete(data, client, {
                  id: id,
                  name: id,
                  pic: pic
                });
              }
github geomoose / gm3 / src / gm3 / components / map.js View on Github external
if(query && query.progress === 'new' && query.layers.length > 0) {
                // issue a 'started' modification so the query is
                //  not run twice.
                this.props.store.dispatch(mapActions.startQuery(query_id));
                // run the query.
                this.runQuery(queries, query_id);
            }
        }

        if(queries.order.length > 0) {
            const query_id = queries.order[0];
            const query = queries[query_id];
            if(query.progress === 'finished') {
                // check the filters
                const filter_json = JSON.stringify(query.filter);
                const filter_md5 = md5(filter_json);

                if(this.currentQueryId !== query_id
                   || this.currentQueryFilter !== filter_md5) {

                    this.renderQueryLayer(query);
                    this.currentQueryId = query_id;
                    this.currentQueryFilter = filter_md5;
                }
            }
        } else {
            // once there are no more queries,
            //  clear the results from the map.
            const results = this.props.mapSources.results;
            if(results && results.features && results.features.length > 0) {
                this.props.store.dispatch(mapSourceActions.clearFeatures('results', 'results'));
            }
github fossasia / susper.com / node_modules / evp_bytestokey / index.js View on Github external
function EVP_BytesToKey (password, salt, keyLen, ivLen) {
  if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
  if (salt) {
    if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
    if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
  }

  var key = Buffer.alloc(keyLen)
  var iv = Buffer.alloc(ivLen)
  var tmp = Buffer.alloc(0)

  while (keyLen > 0 || ivLen > 0) {
    var hash = new MD5()
    hash.update(tmp)
    hash.update(password)
    if (salt) hash.update(salt)
    tmp = hash.digest()

    var used = 0

    if (keyLen > 0) {
      var keyStart = key.length - keyLen
      used = Math.min(keyLen, tmp.length)
      tmp.copy(key, keyStart, 0, used)
      keyLen -= used
    }

    if (used < tmp.length && ivLen > 0) {
      var ivStart = iv.length - ivLen
github sx1989827 / DOClever / node_modules / evp_bytestokey / index.js View on Github external
function EVP_BytesToKey (password, salt, keyBits, ivLen) {
  if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
  if (salt) {
    if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
    if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
  }

  var keyLen = keyBits / 8
  var key = Buffer.alloc(keyLen)
  var iv = Buffer.alloc(ivLen || 0)
  var tmp = Buffer.alloc(0)

  while (keyLen > 0 || ivLen > 0) {
    var hash = new MD5()
    hash.update(tmp)
    hash.update(password)
    if (salt) hash.update(salt)
    tmp = hash.digest()

    var used = 0

    if (keyLen > 0) {
      var keyStart = key.length - keyLen
      used = Math.min(keyLen, tmp.length)
      tmp.copy(key, keyStart, 0, used)
      keyLen -= used
    }

    if (used < tmp.length && ivLen > 0) {
      var ivStart = iv.length - ivLen

md5

js function for hashing messages with MD5

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis