var runBefore=function (code,url,path,method,query,header,body,param) { var Base64=BASE64.encoder,MD5=CryptoJS.MD5,SHA1=CryptoJS.SHA1,SHA256=CryptoJS.SHA256,SHA512=CryptoJS.SHA512,SHA3=CryptoJS.SHA3,RIPEMD160=CryptoJS.RIPEMD160,AES=CryptoJS.AES.encrypt,TripleDES=CryptoJS.TripleDES.encrypt,DES=CryptoJS.DES.encrypt,Rabbit=CryptoJS.Rabbit.encrypt,RC4=CryptoJS.RC4.encrypt,RC4Drop=CryptoJS.RC4Drop.encrypt; try { if(code) { eval(code); } } catch (err) { console.log("Before Error:"+err); } }
var encrypt=function (type,val,salt) { if(!val) { return "" } var arr=["Base64","MD5","SHA-1","SHA-256","SHA-512","SHA-3","RIPEMD-160"]; var arrFunc=[BASE64.encoder,CryptoJS.MD5,CryptoJS.SHA1,CryptoJS.SHA256,CryptoJS.SHA512,CryptoJS.SHA3,CryptoJS.RIPEMD160] var arrSalt=["AES","TripleDES","DES","Rabbit","RC4","RC4Drop"]; var arrSaltFunc=[CryptoJS.AES.encrypt,CryptoJS.TripleDES.encrypt,CryptoJS.DES.encrypt,CryptoJS.Rabbit.encrypt,CryptoJS.RC4.encrypt,CryptoJS.RC4Drop.encrypt]; var index=arr.indexOf(type); if(index>-1) { return arrFunc[index](val).toString(); } index=arrSalt.indexOf(type); if(index>-1) { return arrSaltFunc[index](val,salt).toString(); } return val; }
calculateHash (index, previousHash, timestamp, data, nonce) { return CryptoJS.SHA256(index + previousHash + timestamp + data + nonce).toString() }
app.get('/chats',(req,res)=>{ var user=req.user; if(!user) { res.redirect('/') return; } user.key=crypto.SHA256(nonce,user.username); user.stringify=JSON.stringify(user); res.render('parrot',{user:user}); })
// const crypto = require('crypto') const sha256 = (input) => { // const hash = crypto.createHash('sha256').update(input).digest() if (typeof input !== 'string') { input = CryptoJS.lib.WordArray.create(input) } const hash = Buffer.from( CryptoJS.SHA256(input).toString(CryptoJS.enc.Hex), 'hex' ) return hash }
DB.token.insert({ user: user, token: Crypto.SHA256(token).toString(), creation: Date.now(), 'out-of-date': (new Date(Date.now() + cookieExpire)).getTime() }, function (err) { if (err) { LogWorker.error(err) cb(false) } else { cb(token) } })
app.post('/register',(req,res)=>{ var username=req.body.username; var url=base+username; request.get({uri:url,headers:headers},(err,resp,body)=>{ try { var $=cheerio.load(body); var title=$('title').text(); var name=title.substring(title.indexOf('(')+1,title.indexOf(')')); if(name=="") { throw "No User Exists"; } var profilePic=$('meta[property="og:image"]').attr('content'); var description=$('meta[name="description"]').attr('content'); var profileUrl=url; var user=new User(name,username,profilePic,profileUrl,description); user.key=crypto.SHA256(nonce,user.username); firebase.registerUser(user).then((data)=>{ res.send(JSON.stringify(JSON.stringify(user))); }); } catch (error) { res.send(null); } }) })
app.get('/chats/:user_id',(req,res)=>{ var user=req.user; if(!user) { res.redirect('/') return; } user.stringify=JSON.stringify(user); user.key=crypto.SHA256(nonce,user.username); res.render('parrot',{key:req.params.user_id,user:user}); })
_hash(block){ return CryptoJs.SHA256(stringify(block)).toString(CryptoJs.enc.Hex); }
isValidProof(last_proof,proof){ let hash = CryptoJs.SHA256(`${last_proof}${proof}`).toString(CryptoJs.enc.Hex); return hash.substr(0,4) == "0000"; }
function hexEncodedHash(data) { return crypto.SHA256(data).toString(crypto.enc.Hex); }
/** * SHA256 hash * @param data * @return {*} */ function sha256(data) { let hashBuffer; hashBuffer = CryptoJS.SHA256(data).toString(); return hashBuffer; }
function hexEncodedHash(data) { return crypto.SHA256(data).toString(crypto.enc.Hex); }
function hexEncodedHash(data) { return crypto.SHA256(data).toString(crypto.enc.Hex); }
function hexEncodedHash(data) { return crypto.SHA256(data).toString(crypto.enc.Hex); }