How to use the md5.digest_s function in md5

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 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 mootools / website / lib / BuilderHash.js View on Github external
BuilderDatabase.prototype.saveHash = function(project, packages, callback){
	if (!packages || !packages.length){
		if (callback) callback(null);
		return;
	}

	var packageString = typeof packages == 'string' ? packages : packages.join(';');
	var hash = md5.digest_s(packageString);

	function hashCount(db, cb){
		db.get('SELECT COUNT(*) AS count FROM hashes WHERE md5 = ?', {1: hash}, function(err, row){
			cb(err, row && {count: row.count, db: db, hash: hash});
		});
	}
	function insertIfNotExisting(res, cb){
		if (res.hash){
			cb(null, {hash: hash, packages: packages});
		} else {
			var values = {1: hash, 2: packageString, 3: Math.round(Date.now() / 1000)};
			res.db.run('INSERT INTO hashes (md5, packages, date) VALUES (?, ?, ?)', values, function(error){
				if (error) cb(error);
				else cb(null, {hash: hash, packages: packages});
			});
		}
github Lugribossk / dropwizard-experiment / common / common-client / src / main / javascript / ui / Gravatar.js View on Github external
getUrl() {
        var hash = md5.digest_s(this.props.email.toLocaleLowerCase());
        var size = Math.ceil(this.props.size * (window.devicePixelRatio || 1));
        return "https://secure.gravatar.com/avatar/" + hash + "?d=mm&s=" + size;
    }

md5

js function for hashing messages with MD5

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis