csrf-crypto.js
function getCookieToken(res) {
		var value = res.req.cookies[cookieName(res.req)];
		if (!value)
			return false;

		var parts = value.split('|');

		// If the existing cookie is invalid, reject it.
		if (parts.length !== 3)
			return false;

		// If the user data doesn't match this request's user, reject the cookie
		if (parts[1] !== getUserData(res.req))
			return false;

		var hasher = crypto.createHmac(options.algorithm, cookieKey);
		hasher.update(parts[0]);
		hasher.update("|");	// Don't confuse longer or shorter userDatas
		hasher.update(parts[1]);

		// If the hash doesn't match, reject the cookie
		if (parts[2] !== hasher.digest('base64'))
			return false;

		return parts[0];
	}
function getCookieToken(res) {
		var value = res.req.cookies[cookieName(res.req)];
		if (!value)
			return false;

		var parts = value.split('|');

		// If the existing cookie is invalid, reject it.
		if (parts.length !== 3)
			return false;

		// If the user data doesn't match this request's user, reject the cookie
		if (parts[1] !== getUserData(res.req))
			return false;

		var hasher = crypto.createHmac(options.algorithm, cookieKey);
		hasher.update(parts[0]);
		hasher.update("|");	// Don't confuse longer or shorter userDatas
		hasher.update(parts[1]);

		// If the hash doesn't match, reject the cookie
		if (parts[2] !== hasher.digest('base64'))
			return false;

		return parts[0];
	}
function getCookieToken ( res ) { var value = res . req . cookies [ cookieName ( res . req ) ] ; if ( ! value ) return false ; var parts = value . split ( '|' ) ; // If the existing cookie is invalid, reject it. if ( parts . length !== 3 ) return false ; // If the user data doesn't match this request's user, reject the cookie if ( parts [ 1 ] !== getUserData ( res . req ) ) return false ; var hasher = crypto . createHmac ( options . algorithm , cookieKey ) ; hasher . update ( parts [ 0 ] ) ; hasher . update ( "|" ) ; // Don't confuse longer or shorter userDatas hasher . update ( parts [ 1 ] ) ; // If the hash doesn't match, reject the cookie if ( parts [ 2 ] !== hasher . digest ( 'base64' ) ) return false ; return parts [ 0 ] ; }
Private function that finds an existing cookie token and returns its salt value
Private function that finds an existing cookie token and returns its salt value