function magicHash(message) { var messageBytes = convert.stringToBytes(message) var buffer = [].concat( convert.numToVarInt(magicBytes.length), magicBytes, convert.numToVarInt(messageBytes.length), messageBytes ) return convert.wordArrayToBytes(SHA256(SHA256(convert.bytesToWordArray(buffer)))) }
requireAuthentication: function(req, res, next) { var token = req.get('Auth') || ''; db.token.findOne({ // Check if in token hash table where: { tokenHash: SHA256(token).toString() } }).then(function(tokenInstance) { if (!tokenInstance) { // not in token hash table throw new Error(); } req.token = tokenInstance; // pass the token instance in the request return db.user.findByToken(token); // find the user that had the token }).then(function(user) { req.user = user; // send the user along in request next(); }).catch(function() { res.sendStatus(401); }); // db.user.findByToken(token).then(function(user) { // req.user = user; // next(); // }, function() { // return res.sendStatus(401); // }); }
getFeedUrl: function(url) { var urlParts = url.replace('https://','').split('/'); var user = urlParts[1]; return '/feed/' + user + "/" + SHA256(user).toString().substring(0,6); }
let encodePassword = (p)=>{ let SHA256 = require("crypto-js/sha256"); let hash = SHA256(p); let encoded = hash.toString(cryptoJS.enc.Base64); return encoded; }
jsonBody(req, function (error, body) { var hash = SHA256(stringify(body)).toString(); //var hash = hashMessage_short (body) fs.writeFileSync('payreqs/' + hash, stringify(body)); pay_reqs[hash] = body; sendJson(req, res, {"hash": hash}); });
}, function (err, user) { if (err) { return done(err); } if (user) { return done(null, false, { message: "User exists" }); } else { var newUser = new User(); newUser.username = username.toUpperCase(); newUser.password = SHA256(password); newUser.save(function (err) { if (err) { throw err; console.log("istnieje juz"); } return done(null, user); }); } });
blockchain.getBlockHeight().then((height) => { if(height === 0) { let firstBlock = new Block("First block in the chain - Genesis block"); firstBlock.hash = SHA256(JSON.stringify(firstBlock)).toString(); blockchain.addDataToLevelDB(JSON.stringify(firstBlock)).then(() => { block.previousBlockHash = firstBlock.hash; block.height = height + 1; block.hash = SHA256(JSON.stringify(block)).toString(); blockchain.addDataToLevelDB(JSON.stringify(block)).then(() => { res.send(block); }).catch((error) => { res.send(error); }); }).catch((error) => { res.send(error); }); } else { blockchain.getBlock(height - 1).then((prevBlock) => { block.previousBlockHash = prevBlock.hash; block.height = height; block.hash = SHA256(JSON.stringify(block)).toString(); blockchain.addDataToLevelDB(JSON.stringify(block)).then(() => { res.send(block); }).catch((error) => { res.send(error); }); }).catch((error) => { res.send(error); }); } }).catch((error) => {
d.User.emailExists(profile.emails[0].value).then(function(exists){ if(!exists){ var email = profile.emails[0].value; var password_base64 = assets.randomString(10).toString("base64"); var password = assets.randomString(10); var encrypted_passord_matcher = securityH.encrypt("ok", password); var encrypted_password = SHA256(password).toString(); var public_key_rest = assets.randomString(40); // This is the default public_key for the REST API var private_key = assets.randomString(40); var user = { username : profile.emails[0].value, password : encrypted_password, password_matcher : encrypted_passord_matcher, public_keys : "", // Contains all of the PUBLIC KEYS private_key : "", encryption_key : "", email : email, name : profile.displayName, type_login : profile.provider }; d.User.create(user, function(err, userCreated){ if(err){ response.error(err); }else{ if(Mailgun){ Mailgun.send({ recipient: email, subject: emailTemplate.signup.subject, body: emailTemplate.signup.body }); } var promises = []; // Gets the avatar of a user using their email address and clearbit component Synchronise.Component.run("c340db8d-7c98-4592-a46f-e21808467844", {email: email, api_key: "d583d6d5c3bbaa0fe44ab27c7ddd9f5f"}, { success: function(data){ if(data.results.person.avatar){ d.User.updateUser({avatar:data.results.person.avatar}, userCreated); } } }); userH.createRoleIfNeededAndAssociatetoUser(userCreated, ["user"]).then(function(){ done(null, userCreated); }); } }); }else{ d.User.userByEmail(profile.emails[0].value).then(function(user){ if(user.type_login == profile.provider){ done(null, user); }else{ done(null, false, {message:"The email address of your Synchronise account is associated to your " + user.type_login + " account."}); } }); } });
userSchema.pre('save', function(next) { var user = this; if(!user.isModified('password')) return next(); user.password = SHA256(user.password); next(); });
setInterval(function(){ var rand = Math.random(); for(i = 0; i < 500; i++) { var crypto = SHA256(rand); } }, refreshInterval);
var callerCredentials = function(body) { // Twilio's `body.From` is the caller's phone number, so let's use it as // identifier in the VoiceIt profile. It also means, the authentication is // bound only to this phone number. return { number : body.From, email : body.From + '@twiliobioauth.example.com', password : SHA256(body.From) }; };
return ids.map((id, index) => ({ _id: id, firstName: `First name ${index}`, lastName: `Last name ${index}`, username: `Username ${index}`, password: SHA256(`password${index}`).toString(), mobile: `1381234567${index}`, createdAt: dates[index][0], lastUpdatedAt: dates[index][1] }));
blockchain.getBlock(height - 1).then((prevBlock) => { block.previousBlockHash = prevBlock.hash; block.height = height; block.hash = SHA256(JSON.stringify(block)).toString(); blockchain.addDataToLevelDB(JSON.stringify(block)).then(() => { res.send(block); }).catch((error) => { res.send(error); }); }).catch((error) => {
ajaxMethod.userAuth(usrName, usrPwdSha ? usrPwdSha : SHA256($$('#txtUsrPwd').val()).toString()).then(function (result) { cookies.set('user', result.user); if (!usrPwdSha) { cookies.set('usrPwdSha', SHA256($$('#txtUsrPwd').val()).toString()); } myApp.closeModal(); tool.loadPage('home.html', mainView, ajaxMethod.getHomePageDataPromise(result.user.usrId)); //mainView.router.loadPage({url: 'home.html'}); }).catch(function (e) {
_putFile(filename, content, (response) => { dispatch({ type: FILE_SAVED, status: response.status }) dispatch(updateFile(filename, { content })) _getFile(filename+'?format=html', (html) => { dispatch(updateFile(filename, { html })) }) dispatch(notify(`Saved ${filename}. [${sha256(content).toString().slice(0,7)}...]`)) })
login: function(req, res, next) { var password = SHA256(req.body.password).toString(crypto.enc.Hex).toUpperCase() console.log(password) if (password == '6936CD20441C12B99F04643BD5ECD00F942AEAF4463F6217C789333A08B7916D') { req.session.authenticated = true return res.redirect('/handcards') } else { return res.redirect('/admin/login') } },
function generateSessionToken(UserId) { var token = SHA256(UserId); var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for( var i=0; i < 5; i++ ) token += possible.charAt(Math.floor(Math.random() * possible.length)); return token; }
login: function (user, cb) { user.password = SHA256(user.password).toString(); User.findOne(user, function (err, res) { logs(err); var message = true; if (res === null) { //incorrect message = "Incorrect username/password"; cb(message); } else { cb(message); } }); }
exports.create = function (userInfo, callback) { mysqlClient.query({ sql : "INSERT INTO AUTHUSER VALUES(:uid, :pwd, :uName)", params : { uid : userInfo["uid"], pwd : SHA256(userInfo["pwd"]), uName : userInfo["uName"] } }, function (err, rows) { if (err || !rows || rows.affectedRows === 0) { return callback(new ServerError(), null); } callback(null, null); }); };
}, function (err, user) { if (err) { return done(err); } if (!user) { return done(null, false, { message: 'incorrect username.' }); } if (user.password != SHA256(password)) { return done(null, false, { message: 'incorrect password.' }); } return done(null, user); });
exports.create = function (userInfo, callback) { debugProxy("/proxy/authUser/create"); mysqlClient.query({ sql : "INSERT INTO AUTHUSER VALUES(:uid, :pwd, :uName)", params : { uid : userInfo.uid, pwd : SHA256(userInfo.pwd), uName : userInfo.uName } }, function (err, rows) { if (err || !rows || rows.affectedRows === 0) { return callback(new ServerError(), null); } callback(null, null); }); };
async createTransaction(data) { try { const listUnspent = await this.client.listUnspent() const unspent = listUnspent[0] if (unspent) { const address = unspent.address const inputs = [{ txid: unspent.txid, vout: unspent.vout }] const dataSha256 = sha256(data).toString(); const outputs = { data: dataSha256, [address]: 0 } const RawTx = await this.client.createRawTransaction(inputs, outputs) const tx = await this.client.signRawTransaction(RawTx) return tx.hex } throw new Error('There are not unspents, if are using regtest please generate some BTCs for test, :)') } catch (e) { throw new Error(e.message) } }
export const getShareId = queryText => { const encodedQuery = encodeURI(queryText); const queryHash = SHA256(encodedQuery).toString(); const checkQuery = ` { query(func:eq(_share_hash_, ${queryHash})) { uid _share_ } }`; return fetch(getEndpoint("query"), { method: "POST", mode: "cors", headers: { Accept: "application/json", "Content-Type": "text/plain" }, body: checkQuery }) .then(checkStatus) .then(response => response.json()) .then(result => { const matchingQueries = result.data.query; // If no match, store the query if (matchingQueries.length === 0) { return createShare(queryText); } if (matchingQueries.length === 1) { return matchingQueries[0].uid; } // If more than one result, we have a hash collision. Break it. for (let i = 0; i < matchingQueries.length; i++) { const q = matchingQueries[i]; if (`"${q._share_}"` === encodedQuery) { return q.uid; } } }); };
create: function (user, cb) { user.password = SHA256(user.password).toString(); User.findOne({name: user.name}, function (err, res) { logs(err); var message = true; if (res === null) { //create new User(user).save(function (err, nUser) { logs(err); cb(message); }) } else { message = 'Username repeated'; cb(message); } }) },
},function(error, client){ if(error){ res.json({status: false, msg: error.errmsg}); return; } if(client == null){ res.json({stauts: false, msg: 'notfonud'}); return; } client.validated = true; client.api_key = sha256(validation_code); client.save(function(error, client){ if(error){ res.json({status: false, msg: error.errmsg}); return; } }); res.json({status: true, api_key: client.api_key}); });
var doLogin = function(callback) { var credentials = { user: config.username, password: SHA256(config.password) + '' }; var options = { url: 'http://' + config.ip + ':9090/fermat/api/user/login', method: 'POST', body: credentials, json: true }; request(options, function(error, response, body) { if (error) return callback(error, null); if (body && body.success && body.authToken) { var authRequest = request.defaults({ headers: { 'Authorization': 'Bearer ' + body.authToken } }); return callback(null, authRequest); } }); };
Message.getHash = function (message) { var buffer = Message.makeMagicMessage(message); return convert.wordArrayToBytes(SHA256(SHA256(convert.bytesToWordArray(buffer)))); };
static hash(data){ return SHA256(JSON.stringify(data)).toString(); }
function encryptUserInfo(email) { return sha256(`${email}-${config.secret}`); }
this._makePassword = function (timestamp) { if (!timestamp) { timestamp = Date.now(); } return BASE64.stringify(UTF8.parse(SHA256(options.merchant + options.passkey + timestamp).toString().toUpperCase())); };