handleTorrentDownload(torrent, event) { event.preventDefault(); const baseURI = ConfigStore.getBaseURI(); const link = document.createElement('a'); link.download = torrent.isMultiFile ? `${torrent.name}.tar` : torrent.name; link.href = `${baseURI}api/download?hash=${torrent.hash}`; link.style.display = 'none'; document.body.appendChild(link); link.click(); }
hashPassword(user = {}) { return new Promise(resolve => { if (!user.password || this.isHashed(user.password)) { resolve(null); } else { bcrypt.hash(`${user.password}`, 10, (err, hash) => { resolve(hash); }); } }); }
handleTorrentProcessed(nextTorrentDetails) { const prevTorrentDetails = this.torrentListSummary.torrents[nextTorrentDetails.hash]; if (hasTorrentFinished(prevTorrentDetails, nextTorrentDetails)) { this.services.notificationService.addNotification({ id: 'notification.torrent.finished', data: {name: nextTorrentDetails.name}, }); } }
lab.test('it creates a password hash combination', (done) => { User.generatePasswordHash('bighouseblues', (err, result) => { Code.expect(err).to.not.exist(); Code.expect(result).to.be.an.object(); Code.expect(result.password).to.be.a.string(); Code.expect(result.hash).to.be.a.string(); done(); }); });
it('can be initialized', function() { const subscription = new Subscription( 'className', { key: 'value' }, 'hash' ); expect(subscription.className).toBe('className'); expect(subscription.query).toEqual({ key: 'value' }); expect(subscription.hash).toBe('hash'); expect(subscription.clientRequestIds.size).toBe(0); });
Handlebars.registerHelper('subTemplate', function(name, sourceContext) { if ( ! templateCache[name]) templateCache[name] = Handlebars.compile($('#template-' + name).html()); var template = templateCache[name]; var templateContext = $.extend({}, this, sourceContext.hash); return new Handlebars.SafeString( template(templateContext) ); });
const hashDep = strapi => { const depStr = JSON.stringify(strapi.config.info.dependencies); const readmePath = path.join(strapi.dir, 'README.md'); try { if (fs.existsSync(readmePath)) { return hash(`${depStr}${fs.readFileSync(readmePath)}`); } } catch (err) { return hash(`${depStr}`); } return hash(`${depStr}`); }
function hashchain (prev, cur) { // Important: If two messages do not have a natrual seperation // it is very important to use a seperating token. Example being // concatting 'car' and 'pet', which without a seperator could // introduce a subtle security issue in using the token 'carpet' var inputBuf = Buffer.from(prev.hash + JSON.stringify(cur)) // Preallocate our hash result buffer var hashBuf = Buffer.alloc(sodium.crypto_generichash_BYTES) sodium.crypto_generichash(hashBuf, inputBuf) return hashBuf.toString('base64') }
/** * */ Handlebars.registerHelper('if_eq', function(context, options) { var compare = context; // Get length if context is an object if (context instanceof Object && ! (options.hash.compare instanceof Object)) compare = Object.keys(context).length; if (compare === options.hash.compare) return options.fn(this); return options.inverse(this); });
/** * hashes a password * @param {string} password - password to hash * @returns {string} hashed password */ const hashPassword = password => bcrypt.hash(password, 10)
hashPassword(user = {}) { return new Promise(resolve => { if (!user.password || this.isHashed(user.password)) { resolve(null); } else { bcrypt.hash(`${user.password}`, 10, (err, hash) => { resolve(hash); }); } }); }
/** * hashes a password * @param {string} password - password to hash * @returns {string} hashed password */ const hashPassword = password => bcrypt.hash(password, 10)