当前位置: 首页>>代码示例>>C++>>正文


C++ Sha1Hash类代码示例

本文整理汇总了C++中Sha1Hash的典型用法代码示例。如果您正苦于以下问题:C++ Sha1Hash类的具体用法?C++ Sha1Hash怎么用?C++ Sha1Hash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Sha1Hash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: transform

void AccountMgr::UpdateAccount(Account * acct, Field * field)
{
	uint32 id = field[0].GetUInt32();
	if(id != acct->AccountId)
	{
		//printf("Account %u `%s` is a duplicate.\n", id, acct->Username.c_str());
		sLog.outColor(TYELLOW, " >> deleting duplicate account %u [%s]...", id, acct->Username.c_str());
		sLog.outColor(TNORMAL, "\n");
		sLogonSQL->Execute("DELETE FROM accounts WHERE acct=%u", id);
		return;
	}
	acct->AccountId	  = field[0].GetUInt32();
	acct->Username	   = field[1].GetString();
	acct->Password	   = field[2].GetString();
	acct->GMFlags		= field[3].GetString();
	acct->AccountFlags   = field[4].GetUInt32();
	acct->Banned		 = field[5].GetUInt32();

	// Convert username/password to uppercase. this is needed ;)
	transform(acct->Username.begin(), acct->Username.end(), acct->Username.begin(), towupper);
	transform(acct->Password.begin(), acct->Password.end(), acct->Password.begin(), towupper);

	Sha1Hash hash;
	hash.UpdateData((acct->Username + ":" + acct->Password));
	hash.Finalize();
	memcpy(acct->SrpHash, hash.GetDigest(), 20);
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:27,代码来源:AccountCache.cpp

示例2: SendProof

void AuthSocket::SendProof(Sha1Hash sha)
{
    switch(_build)
    {
        case 5875:                                          // 1.12.1
        case 6005:                                          // 1.12.2
        {
            sAuthLogonProof_S_BUILD_6005 proof;
            memcpy(proof.M2, sha.GetDigest(), 20);
            proof.cmd = AUTH_LOGON_PROOF;
            proof.error = 0;
            proof.unk2 = 0x00;

            SendBuf((char *)&proof, sizeof(proof));
            break;
        }
        case 8606:                                          // 2.4.3
        case 10505:                                         // 3.2.2a
        default:                                            // or later
        {
            sAuthLogonProof_S proof;
            memcpy(proof.M2, sha.GetDigest(), 20);
            proof.cmd = AUTH_LOGON_PROOF;
            proof.error = 0;
            proof.unk1 = 0x00800000;
            proof.unk2 = 0x00;
            proof.unk3 = 0x00;

            SendBuf((char *)&proof, sizeof(proof));
            break;
        }
    }
}
开发者ID:FLaM666,项目名称:evo-X,代码行数:33,代码来源:AuthSocket.cpp

示例3: memset

LogonCommHandler::LogonCommHandler()
{
    idhigh = 1;
    next_request = 1;
    pings = !Config.MainConfig.GetBoolDefault("LogonServer", "DisablePings", false);
    string logon_pass = Config.MainConfig.GetStringDefault("LogonServer", "RemotePassword", "r3m0t3");

    // sha1 hash it
    Sha1Hash hash;
    hash.UpdateData(logon_pass);
    hash.Finalize();

    memset(sql_passhash, 0, 20);
    memcpy(sql_passhash, hash.GetDigest(), 20);

    // player limit
    pLimit = Config.MainConfig.GetIntDefault("Server", "PlayerLimit", 500);
    if (pLimit == 0) pLimit = 1;
    server_population = 0;

    _realmType = 0;

    // cleanup
    servers.clear();
    realms.clear();
}
开发者ID:TheGhostGroup,项目名称:AscEmu,代码行数:26,代码来源:LogonCommHandler.cpp

示例4: arcemu_TOUPPER

void LogonCommHandler::TestConsoleLogon(string& username, string& password, uint32 requestnum)
{
	string newuser = username;
	string newpass = password;
	string srpstr;

	arcemu_TOUPPER(newuser);
	arcemu_TOUPPER(newpass);

	srpstr = newuser + ":" + newpass;

	// Send request packet to server.
	map<LogonServer*, LogonCommClientSocket*>::iterator itr = logons.begin();
	if(logons.size() == 0 || itr->second == 0)
	{
		// No valid logonserver is connected.
		return;
	}

	Sha1Hash hash;
	hash.UpdateData(srpstr);
	hash.Finalize();

	WorldPacket data(RCMSG_TEST_CONSOLE_LOGIN, 100);
	data << requestnum;
	data << newuser;
	data.append(hash.GetDigest(), 20);

	itr->second->SendPacket(&data, false);
}
开发者ID:AwkwardDev,项目名称:Descent-core-scripts-3.3.5,代码行数:30,代码来源:LogonCommHandler.cpp

示例5: SendProof

void AuthSocket::SendProof(Sha1Hash sha)
{
    switch (_build)
    {
        case 5875:                                          // 1.12.1
        case 6005:                                          // 1.12.2
        case 6141:                                          // 1.12.3
        {
            sAuthLogonProof_S_BUILD_6005 proof;
            memcpy(proof.M2, sha.GetDigest(), 20);
            proof.cmd = CMD_AUTH_LOGON_PROOF;
            proof.error = 0;
            proof.unk2 = 0x00;

            send((char*)&proof, sizeof(proof));
            break;
        }
        case 8606:                                          // 2.4.3
        case 10505:                                         // 3.2.2a
        case 11159:                                         // 3.3.0a
        case 11403:                                         // 3.3.2
        case 11723:                                         // 3.3.3a
        case 12340:                                         // 3.3.5a
        case 13623:                                         // 4.0.6a
        case 15050:                                         // 4.3.0
        case 15595:                                         // 4.3.4
        case 16357:                                         // 5.1.0
		case 16992:											// 5.3.0
        case 17055:                                         // 5.3.0
		case 17116:                                         // 5.3.0
		case 17128:                                         // 5.3.0
        case 17538:                                         // 5.4.1
        case 17658:                                         // 5.4.2
        case 17688:                                         // 5.4.2a
        case 17898:                                         // 5.4.7
        case 17930:                                         // 5.4.7
        case 17956:                                         // 5.4.7
        case 18019:                                         // 5.4.7
        case 18291:                                         // 5.4.8
        case 18414:                                         // 5.4.8
        default:                                            // or later
        {
            sAuthLogonProof_S proof;
            memcpy(proof.M2, sha.GetDigest(), 20);
            proof.cmd = CMD_AUTH_LOGON_PROOF;
            proof.error = 0;
            proof.accountFlags = ACCOUNT_FLAG_PROPASS;
            proof.surveyId = 0x00000000;
            proof.unkFlags = 0x0000;

            send((char*)&proof, sizeof(proof));
            break;
        }
    }
}
开发者ID:OrAlien,项目名称:server,代码行数:55,代码来源:AuthSocket.cpp

示例6:

LogonCommHandler::LogonCommHandler()
{
	idhigh = 1;
	next_request = 1;
	pings = !Config.MainConfig.GetBoolDefault("LogonServer", "DisablePings", false);
	string logon_pass = Config.MainConfig.GetStringDefault("LogonServer", "RemotePassword", "r3m0t3");
	
	// sha1 hash it
	Sha1Hash hash;
	hash.UpdateData(logon_pass);
	hash.Finalize();
	memcpy(sql_passhash, hash.GetDigest(), 20);
}
开发者ID:Chero,项目名称:abcwow,代码行数:13,代码来源:LogonCommHandler.cpp

示例7: Find

int ZeroState::Find(const Sha1Hash &root_hash)
{
    //fprintf(stderr,"swift: zero: Got request for %s\n",root_hash.hex().c_str() );

    //std::string file_name = "content.avi";
    std::string file_name = contentdir_+FILE_SEP+root_hash.hex();
    uint32_t chunk_size=SWIFT_DEFAULT_CHUNK_SIZE;

    dprintf("%s #0 zero find %s from %s\n",tintstr(),file_name.c_str(), getcwd_utf8().c_str() );

    std::string reqfilename = file_name;
    int ret = file_exists_utf8(reqfilename);
    if (ret < 0 || ret == 0 || ret == 2)
        return -1;
    reqfilename = file_name+".mbinmap";
    ret = file_exists_utf8(reqfilename);
    if (ret < 0 || ret == 0 || ret == 2)
        return -1;
    reqfilename = file_name+".mhash";
    ret = file_exists_utf8(reqfilename);
    if (ret < 0 || ret == 0 || ret == 2)
        return -1;

    // Open as ZeroState
    SwarmID swarmid(root_hash);
    return swift::Open(file_name, swarmid, "", false, POPT_CONT_INT_PROT_MERKLE, true);
}
开发者ID:JuanCabre,项目名称:libswift,代码行数:27,代码来源:zerostate.cpp

示例8: parse_handshake_info

//Peer_id 为返回对方peer_id;
bool parse_handshake_info(const t_byte* pbuf, Sha1Hash &info_hash, PeerID &peer_id, t_byte ext_info[8])
{
		assert(pbuf != 0);
		
		if(pbuf[0] != PROTOCOL_LENGTH)
		{
				
				DEBUG_PRINT0("invalid protocol length\n");
				return false;
		}
		
		//DEBUG_PRINT1("%s\n", (const char*)&pbuf[1]);
		if(memcmp(&pbuf[1], PROTOCOL_STRING, PROTOCOL_LENGTH) == 0)
		{
				//DEBUG_PRINT0("invalid protocol string\n");
				memcpy(ext_info, &pbuf[20], 8); 
				info_hash.Reset(&pbuf[28]);
				peer_id.Reset(&pbuf[48]);
				return true;
		}else
		{
				DEBUG_PRINT0("invalid protocol string\n");
				return false;
		}
		
		
}
开发者ID:solidusex,项目名称:ragebtclient,代码行数:28,代码来源:ConnValidator.cpp

示例9: SendProof

void AuthSocket::SendProof(Sha1Hash sha)
{
    switch(_build)
    {
        case 5875:                                          // 1.12.1
        case 6005:                                          // 1.12.2
        {
            sAuthLogonProof_S_BUILD_6005 proof;
            memcpy(proof.M2, sha.GetDigest(), 20);
            proof.cmd = AUTH_LOGON_PROOF;
            proof.error = 0;
            proof.unk2 = 0x00;

            send((char *)&proof, sizeof(proof));
            break;
        }
        case 8606:                                          // 2.4.3
        case 10505:                                         // 3.2.2a
        case 11159:                                         // 3.3.0a
        case 11403:                                         // 3.3.2
        case 11573:											// 3.3.3-11573
		case 11643:											// 3.3.3-11643
		case 11655:											// 3.3.3-11655
		case 11685:											// 3.3.3-11685
        case 11723:                                         // 3.3.3a-11723
		case 11927:                                         // 4.0.0-11927
		case 12025:                                         // 4.0.0-12025
		case 12065:                                         // 4.0.0-12065
		case 12122:                                         // 4.0.0-12122
		case 12164:                                         // 4.0.0-12164
		case 12232:                                         // 4.0.0-12232
        default:                                            // or later
        {
            sAuthLogonProof_S proof;
            memcpy(proof.M2, sha.GetDigest(), 20);
            proof.cmd = AUTH_LOGON_PROOF;
            proof.error = 0;
            proof.unk1 = 0x00800000;
            proof.unk2 = 0x00;
            proof.unk3 = 0x00;

            send((char *)&proof, sizeof(proof));
            break;
        }
    }
}
开发者ID:webdes27,项目名称:cataclysm,代码行数:46,代码来源:AuthSocket.cpp

示例10: build_hand_shake

std::vector<t_byte> build_hand_shake(const Sha1Hash &info_hash, const PeerID &local_peer_id)
{
		std::vector<t_byte>  buf(68, 0);
		buf[0] = PROTOCOL_LENGTH;
		memcpy(&buf[1], PROTOCOL_STRING, (t_uint32)PROTOCOL_LENGTH);
		memcpy(&buf[28], info_hash.GetRawData(), 20);
		memcpy(&buf[48], local_peer_id.GetRawData(), 20);
		return buf;
}
开发者ID:solidusex,项目名称:ragebtclient,代码行数:9,代码来源:ConnValidator.cpp

示例11: AddAccount

void AccountMgr::AddAccount()
{
	Account* acct = new Account;
	Sha1Hash hash;
	string Username = "test";
	string Password = "test";
	acct->AccountId				= 1;
	acct->AccountFlags			= 1;
	acct->Banned				= 1;
	if((uint32)UNIXTIME > acct->Banned && acct->Banned != 0 && acct->Banned != 1)   //1 = perm ban?
	{
		//Accounts should be unbanned once the date is past their set expiry date.
		acct->Banned = 0;
		//me go boom :(
		//printf("Account %s's ban has expired.\n",acct->UsernamePtr->c_str());
		//sLogonSQL->Execute("UPDATE accounts SET banned = 0 WHERE acct=%u", acct->AccountId);
	}
	acct->SetGMFlags("test");
	acct->Locale[0] = 'e';
	acct->Locale[1] = 'n';
	acct->Locale[2] = 'U';
	acct->Locale[3] = 'S';
	acct->forcedLocale = false;

	acct->Muted = 1;
	if((uint32)UNIXTIME > acct->Muted && acct->Muted != 0 && acct->Muted != 1)   //1 = perm ban?
	{
		//Accounts should be unbanned once the date is past their set expiry date.
		acct->Muted = 0;
		//LOG_DEBUG("Account %s's mute has expired.",acct->UsernamePtr->c_str());
		//sLogonSQL->Execute("UPDATE accounts SET muted = 0 WHERE acct=%u", acct->AccountId);
	}
	// Convert username/password to uppercase. this is needed ;)
	mnet_TOUPPER(Username);
	mnet_TOUPPER(Password);

	// prefer encrypted passwords over nonencrypted
	// Prehash the I value.
	hash.UpdateData((Username + ":" + Password));
	hash.Finalize();
	memcpy(acct->SrpHash, hash.GetDigest(), 20);
	AccountDatabase[Username] = acct;
}
开发者ID:edolphin-ydf,项目名称:hydzhengtu,代码行数:43,代码来源:InfoCore.cpp

示例12: CmdGwSendINFOHashChecking

void CmdGwSendINFOHashChecking(cmd_gw_t* req, Sha1Hash root_hash)
{
	// Send INFO DLSTATUS_HASHCHECKING message.

    char cmd[MAX_CMD_MESSAGE];
	sprintf(cmd,"INFO %s %d %lli/%lli %lf %lf %u %u\r\n",root_hash.hex().c_str(),DLSTATUS_HASHCHECKING,(uint64_t)0,(uint64_t)0,0.0,0.0,0,0);

    //fprintf(stderr,"cmd: SendINFO: %s", cmd);
    send(req->cmdsock,cmd,strlen(cmd),0);
}
开发者ID:rauljim,项目名称:libswift,代码行数:10,代码来源:cmdgw.cpp

示例13: CmdGwGotMAXSPEED

void CmdGwGotMAXSPEED(Sha1Hash &want_hash, data_direction_t ddir, double speed)
{
	// Set maximum speed on the specified download
	fprintf(stderr,"cmd: GotMAXSPEED: %s %d %lf\n",want_hash.hex().c_str(),ddir,speed);

	cmd_gw_t* req = CmdGwFindRequestByRootHash(want_hash);
	if (req == NULL)
    	return;
    FileTransfer *ft = FileTransfer::file(req->transfer);
	ft->SetMaxSpeed(ddir,speed);
}
开发者ID:rauljim,项目名称:libswift,代码行数:11,代码来源:cmdgw.cpp

示例14: ContentTransfer

FileTransfer::FileTransfer(int td, std::string filename, const Sha1Hash& root_hash, bool force_check_diskvshash, popt_cont_int_prot_t cipm, uint32_t chunk_size, bool zerostate) :
    ContentTransfer(FILE_TRANSFER), availability_(NULL), zerostate_(zerostate)
{
    td_ = td;

    Handshake hs;
    hs.cont_int_prot_ = cipm;
    SetDefaultHandshake(hs);

    std::string destdir;
    int ret = file_exists_utf8(filename);
    if (ret == 2 && root_hash != Sha1Hash::ZERO) {
        // Filename is a directory, download root_hash there
        destdir = filename;
        filename = destdir+FILE_SEP+root_hash.hex();
    } else {
        destdir = dirname_utf8(filename);
        if (destdir == "")
            destdir = ".";
    }

    // MULTIFILE
    storage_ = new Storage(filename,destdir,td_,0);

    std::string hash_filename;
    hash_filename.assign(filename);
    hash_filename.append(".mhash");

    std::string binmap_filename;
    binmap_filename.assign(filename);
    binmap_filename.append(".mbinmap");

    // Arno, 2013-02-25: Create HashTree even when PROT_NONE to enable
    // automatic size determination via peak hashes.
    if (!zerostate_)
    {
        hashtree_ = (HashTree *)new MmapHashTree(storage_,root_hash,chunk_size,hash_filename,force_check_diskvshash,binmap_filename);
        availability_ = new Availability(SWIFT_MAX_OUTGOING_CONNECTIONS);

        if (ENABLE_VOD_PIECEPICKER) 
            picker_ = new VodPiecePicker(this);
        else 
			picker_ = new RFPiecePicker(this);
        picker_->Randomize(rand()&63);
    }
    else
    {
	// ZEROHASH
	hashtree_ = (HashTree *)new ZeroHashTree(storage_,root_hash,chunk_size,hash_filename,binmap_filename);
    }

    UpdateOperational();
}
开发者ID:JuanCabre,项目名称:libswift,代码行数:53,代码来源:transfer.cpp

示例15: CalculateShaPassHash

std::string AccountMgr::CalculateShaPassHash(std::string& name, std::string& password)
{
    Sha1Hash sha;
    sha.Initialize();
    sha.UpdateData(name);
    sha.UpdateData(":");
    sha.UpdateData(password);
    sha.Finalize();

    std::string encoded;
    hexEncodeByteArray(sha.GetDigest(), sha.GetLength(), encoded);

    return encoded;
}
开发者ID:beyourself,项目名称:RustEmu-Core,代码行数:14,代码来源:AccountMgr.cpp


注:本文中的Sha1Hash类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。