Beispiel #1
0
		void Md5Adapter::CalculateDigest(std::vector<unsigned char> data, std::vector<unsigned char> & digest)
		{
			CryptoPP::Weak1::MD5 hash;
			digest.assign(CryptoPP::Weak1::MD5::DIGESTSIZE, 0);

			hash.CalculateDigest(&digest[0], &data[0], data.size());
		}
Beispiel #2
0
std::string	MD5encode::encode(std::string const &message)
{
  CryptoPP::Weak1::MD5	hash;
  byte digest[ CryptoPP::Weak1::MD5::DIGESTSIZE ];

  hash.CalculateDigest( digest, (byte*) message.c_str(), message.length() );

  CryptoPP::HexEncoder encoder;
  std::string output;
  encoder.Attach( new CryptoPP::StringSink( output ) );
  encoder.Put( digest, sizeof(digest) );
  encoder.MessageEnd();
  std::transform(output.begin(), output.end(), output.begin(), ::tolower);
  return (output);
}
Beispiel #3
0
// Login subscriber
bool filmonAPIlogin(std::string username, std::string password) {

	bool res = filmonAPIgetSessionKey();
	if (res) {
		std::cerr << "FilmonAPI: logging in user" << std::endl;
		filmonUsername = username;
		filmonpassword = password;
		// Password is MD5 hex
		CryptoPP::Weak1::MD5 hash;
		byte digest[CryptoPP::Weak1::MD5::DIGESTSIZE];
		hash.CalculateDigest(digest, (byte*) password.c_str(),
				password.length());
		CryptoPP::HexEncoder encoder;
		std::string md5pwd;
		encoder.Attach(new CryptoPP::StringSink(md5pwd));
		encoder.Put(digest, sizeof(digest));
		encoder.MessageEnd();
		toLowerCase(md5pwd);
		std::string params = "login="******"&password="******"tv/api/login", sessionKeyParam + "&" + params);
		if (res) {
			Json::Value root;
			Json::Reader reader;
			reader.parse(&response.memory[0],
					&response.memory[(long) response.size - 1], root);
			// Favorite channels
			channelList.clear();
			Json::Value favouriteChannels = root["favorite-channels"];
			unsigned int channelCount = favouriteChannels.size();
			for (unsigned int channel = 0; channel < channelCount; channel++) {
				Json::Value chId = favouriteChannels[channel]["channel"]["id"];
				channelList.push_back(chId.asUInt());
				std::cerr << "FilmonAPI: added channel " << chId.asUInt()
								<< std::endl;
			}
			clearResponse();
		}
	}
	return res;
}
bool CCryptoModulus::InitCrypto(BYTE *temp, DWORD length)
{
    int hashid = 0;
    BYTE digest[2048];


    memset(digest, 0, sizeof(digest));


    if (length >= 10)
    {
        hashid = temp[4] ^ (temp[3] | (temp[1] ^ temp[0]) < temp[2] % 3);
    }
    else
    {
        hashid = temp[0];
    }


    hashid = (hashid % 11) - 1;


    switch (hashid)
    {
        case 0:
        {
            CryptoPP::SHA256 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[0] % 10;
            this->InitCrypto(this->m_algorithm, digest, 32);
        }
        break;


        case 2:
        {
            CryptoPP::SHA512 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[1] % 10;
            this->InitCrypto(this->m_algorithm, digest, 64);
        }
        break;
        
        case 3:
        {
            CryptoPP::SHA384 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[2] % 10;
            this->InitCrypto(this->m_algorithm, digest, 48);
        }
        break;


        case 4:
        {
            CryptoPP::Weak1::MD4 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[3] % 10;
            this->InitCrypto(this->m_algorithm, digest, 16);
        }
        break;


        case 5:
        {
            CryptoPP::Weak1::MD5 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[4] % 10;
            this->InitCrypto(this->m_algorithm, digest, 16);
        }
        break;


        case 6:
        {
            CryptoPP::RIPEMD160 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[5] % 10;
            this->InitCrypto(this->m_algorithm, digest, 20);
        }
        break;


        case 7:
        {
            CryptoPP::RIPEMD320 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[6] % 10;
            this->InitCrypto(this->m_algorithm, digest, 40);
        }
        break;


        case 8:
        {
            CryptoPP::RIPEMD128 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[7] % 10;
            this->InitCrypto(this->m_algorithm, digest, 16);
        }
        break;


        case 9:
        {
            CryptoPP::RIPEMD256 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[8] % 10;
            this->InitCrypto(this->m_algorithm, digest, 32);
        }
        break;


        default:
        {
            CryptoPP::Weak1::MD5 hash;
            hash.Update(temp, length);
            hash.Final(digest);


            this->m_algorithm = digest[9] % 10;
            this->InitCrypto(this->m_algorithm, digest, 16);
        }
        break;
    }


    return true;
}