bool RelaxNGValidator::LoadGrammar(const std::string& grammar) { shared_ptr<RelaxNGSchema> schema; { CScopeLock lock(g_SchemaCacheLock); std::map<std::string, shared_ptr<RelaxNGSchema> >::iterator it = g_SchemaCache.find(grammar); if (it == g_SchemaCache.end()) { schema = shared_ptr<RelaxNGSchema>(new RelaxNGSchema(grammar)); g_SchemaCache[grammar] = schema; } else { schema = it->second; } } m_Schema = schema->m_Schema; if (!m_Schema) return false; MD5 hash; hash.Update((const u8*)grammar.c_str(), grammar.length()); m_Hash = hash; return true; }
void md5buff(const char* _in, char *_out, size_t _size_in) { MD5_CTX m_md5_ctx; MD5 m; m.MD5Init ( &m_md5_ctx ); m.MD5Update ( &m_md5_ctx, (unsigned char*)_in, _size_in); m.MD5Final ( (unsigned char*)_out, &m_md5_ctx); }
IUserPacket::IUserPacket(LPCTSTR xUserId, LPCTSTR xPass) : IPacket( ICP_USER ) { MD5 ctx; BYTE xMD5Hash[16]; ctx.update( (LPBYTE)xPass, _tcslen(xPass) ); ctx.finalize(); ctx.raw_digest( xMD5Hash ); CopyMemory( UserId, xUserId, 21 ); ctx.tostring( (LPBYTE)MD5Hashing ); }
int CalcHashBytes(LPTSTR xHashing, LPCTSTR xString) { MD5 ctx; BYTE pHash[16]; ctx.update( (LPBYTE)xString, _tcslen(xString) ); ctx.finalize(); ctx.raw_digest( pHash ); ctx.tostring( (LPBYTE)xHashing ); return 32; }
void FileCodeWriter::WriteBuffer() { const static unsigned char MICROSOFT_BOM[3] = { 0xEF, 0xBB, 0xBF }; // Compare buffer with existing file (if any) to determine if // writing the file is necessary bool shouldWrite = true; std::ifstream fileIn(m_filename.mb_str(wxConvFile), std::ios::binary | std::ios::in); std::string buf; if (fileIn) { MD5 diskHash(fileIn); unsigned char* diskDigest = diskHash.raw_digest(); MD5 bufferHash; if (m_useMicrosoftBOM) { bufferHash.update(MICROSOFT_BOM, 3); } const std::string& data = m_useUtf8 ? _STDSTR( m_buffer ) : _ANSISTR( m_buffer ); if (!m_useUtf8) buf = data; bufferHash.update( reinterpret_cast< const unsigned char* >( data.c_str() ), data.size() ); bufferHash.finalize(); unsigned char* bufferDigest = bufferHash.raw_digest(); shouldWrite = ( 0 != std::memcmp( diskDigest, bufferDigest, 16 ) ); delete [] diskDigest; delete [] bufferDigest; } if ( shouldWrite ) { wxFile fileOut; if (!fileOut.Create(m_filename, true)) { wxLogError( _("Unable to create file: %s"), m_filename.c_str() ); return; } if (m_useMicrosoftBOM) { fileOut.Write(MICROSOFT_BOM, 3); } if (!m_useUtf8) fileOut.Write(buf.c_str(), buf.length()); else fileOut.Write(m_buffer); } }
/* * @brief Calculate MD5 value */ void md5string(const char* _in, char *_out) { MD5_CTX m_md5_ctx; MD5 m; m.MD5Init ( &m_md5_ctx ); m.MD5Update ( &m_md5_ctx, (unsigned char*)_in, strlen(_in)); m.MD5Final ( (unsigned char*)_out, &m_md5_ctx); }
const wxString wxMD5::GetDigest() { MD5 context; context.update((unsigned char*)m_szText.mb_str().data(), m_szText.Len()); context.finalize(); wxString md5(context.hex_digest()); md5.MakeUpper(); return md5; }
void Message::addMessageId() { if ( header()->field( HeaderField::MessageId ) ) return; MD5 x; x.add( rfc822() ); header()->add( "Message-Id", "<" + x.hash().e64().mid( 0, 21 ) + ".md5@" + Configuration::hostname() + ">" ); }
UnicodeString __fastcall md5(UnicodeString Pass) { wchar_t *ww; MD5 *md; ww = Pass.w_str(); std::wstring wstr = ww; std::string str = std::string(wstr.begin(), wstr.end()); md = new MD5(); md->add(str.c_str(), str.length()); str = md->getHash(); return UnicodeString(str.c_str()); }
void Hashr::md5Hash(const char* file, path hash_item) { MD5 hash = MD5(file, 32); hashValue = hash.getHash(); ofstream fout; fout.open("C:/Users/darry/Desktop/MD5_HashTable.txt", ofstream::app); fout << hashValue << endl; fout.close(); //cout << "MD5: " << hashValue << endl; //cout << "MD5HashTable value: " << md5Table[hashValue] << endl; if (md5Table[hashValue] == hashValue) { suspect = true; } }
bool CdbInterface::authenticate(const char* username, const char* password) { SingleLock l(&dbMutex_); if (!l.lock()) return false; ReadLockSQLTable sqlLock(dbase_, "pokeruser"); if (!sqlLock.success_) return false; char query[MAXQUERYSIZE]; char* dbPassword = NULL; MD5 context; string u = sqlfy(username); context.update((unsigned char *)password, (int)strlen(password)); context.finalize(); memset(query, 0x0, MAXQUERYSIZE); sprintf(query, "SELECT password FROM pokeruser WHERE username='******'", u.c_str()); if (!dbase_->dbQuery(query)) { if (DEBUG & DEBUG_DATABASE) { printf("Query to authenticate %s failed!\n", username); printf("Reason: %s\n", mysql_error(dbase_->mySQLQuery_)); } return false; } dbPassword = dbase_->dbFetchRow(); if (dbPassword == NULL) { char s[200]; sprintf(s, "CTable::tableLogin: User %s does not exist in database!", username); Sys_LogError(s); return false; } else if (strcmp(dbPassword, context.hex_digest())) { char s[200]; sprintf(s, "CTable::tableLogin: wrong password %s for user %s.", password, username); Sys_LogError(s); return false; } return true; };
static void hashString(MD5& md5, const String& string) { const uint8_t zero = 0; if (string.is8Bit() && string.containsOnlyASCII()) { md5.addBytes(string.characters8(), string.length()); md5.addBytes(&zero, 1); return; } auto cString = string.utf8(); md5.addBytes(reinterpret_cast<const uint8_t*>(cString.data()), cString.length()); md5.addBytes(&zero, 1); }
int main(int argc, char ** argv) { unsigned int iterations = 1 << 15; unsigned int tests = 10000; unsigned char salt1[] = {0x97, 0x48, 0x6C, 0xAA, 0x22, 0x5F, 0xE8, 0x77, 0xC0, 0x35, 0xCC, 0x03, 0x73, 0x23, 0x6D, 0x51}; char path[] = "C:\\Documents and Settings\\john\\Local Settings\\Application Data\\Google\\Chrome\\Application~dir1"; unsigned char null = 0x00; cout << "Number of tests: " << iterations << endl; cout << "Iterations per hash: " << tests << endl; int start = clock(); for(int y = 0; y < iterations; y++) { MD5 md5; for(int x = 0; x < strlen(path); x++) { md5.update((unsigned char *)path + x, 1); md5.update((unsigned char *)&null, 1); } md5.update(salt1, 16); unsigned char hash[16]; md5.finalize(); memcpy(hash, md5.digest, 16); for(int x = 0; x < tests; x++) { MD5 m; m.update(hash, 16); m.finalize(); memcpy(hash, m.digest, 16); } } int end = clock(); double orig = end - start; printf ("Original: (%f seconds) %f hashes per second.\n", ((float)end - start)/CLOCKS_PER_SEC, ((double)iterations + 1)/(((float)end - start)/CLOCKS_PER_SEC)); start = clock(); for(int y = 0; y < iterations; y++) { MD5 md5i; for(int x = 0; x < strlen(path); x++) { md5i.update((unsigned char *)path + x, 1); md5i.update((unsigned char *)&null, 1); } md5i.update(salt1, 16); md5i.finalize(tests); } end = clock(); orig = end - start; printf ("Original: (%f seconds) %f hashes per second.\n", ((float)end - start)/CLOCKS_PER_SEC, ((double)iterations + 1)/(((float)end - start)/CLOCKS_PER_SEC)); cout << endl << "Should be 76405ce7f4e75e352c1cd4d9aeb6be41" << endl; }
inline void TestMD5() { // echo -n 'qwertyuiopqwertyuiopasdfghjklasdfghjkl' | md5sum char b[] = "qwertyuiopqwertyuiopasdfghjklasdfghjkl"; MD5 r; r.Update((const unsigned char*)b, 15); r.Update((const unsigned char*)b + 15, strlen(b) - 15); char rs[33]; Stroka s(r.End(rs)); s.to_lower(); UNIT_ASSERT_EQUAL(s, Stroka("3ac00dd696b966fd74deee3c35a59d8f")); }
bool CdbInterface::authenticate(const char* username, const char* password) { ReadLockSQLTable sqlLock(dbase_, "pokeruser"); CStrOut query; char* dbPassword = NULL; string u = sqlfy(username); MD5 context; context.update((unsigned char*)password, strlen(password)); context.finalize(); query << "SELECT password FROM pokeruser WHERE username='******'\''; if (!dbase_->dbQuery(query.str())) { if (DEBUG & DEBUG_DATABASE) { printf("Query to authenticate %s failed!\n", username); } return false; } dbPassword = dbase_->dbFetchRow(); if (dbPassword == NULL) { if (DEBUG & DEBUG_DATABASE) { printf("User %s does not exist in database!\n", username); } return false; } //MP else if (strcmp(dbPassword, password)) { if (DEBUG & DEBUG_DATABASE) { printf("User supplied password and password on file don't match!\n"); } return false; } return true; };
/** * Generate BMP router HASH * * \param [in,out] client Reference to client info used to generate the hash. * * \return client.hash_id will be updated with the generated hash */ void BMPListener::hashRouter(ClientInfo &client) { string c_hash_str; MsgBusInterface::hash_toStr(cfg->c_hash_id, c_hash_str); MD5 hash; hash.update((unsigned char *)client.c_ip, strlen(client.c_ip)); hash.update((unsigned char *)c_hash_str.c_str(), c_hash_str.length()); hash.finalize(); // Save the hash unsigned char *hash_bin = hash.raw_digest(); memcpy(client.hash_id, hash_bin, 16); delete[] hash_bin; }
// This mfunction creates 'numPlayers' player entries // with username and password 'bot_X'. bool CdbInterface::createTestPlayers(int numPlayers) { bool rc = true; for (int i = 0; i < numPlayers; i++) { char buf[17]; sprintf(buf, "bot_%i", i + 1); // First check that the player is not already there! char query[MAXQUERYSIZE]; sprintf(query, "SELECT username FROM pokeruser where username='******';", buf); if (!dbase_->dbQuery(query)) { Sys_LogError("Query to create test player failed(0)."); return false; } const char* fetched = dbase_->dbFetchRow(); if (fetched == NULL) { // Okay now create the player MD5 context; context.update((unsigned char*)buf, strlen(buf)); context.finalize(); sprintf(query, "INSERT INTO customers (username, password, cc1_type, cc1_number, spam) VALUES ('%s', '%s', 'asiV', '1', 1);", buf, context.hex_digest()); if (!dbase_->dbQuery(query)) { Sys_LogError("Query to create test player failed(1)."); return false; } sprintf(query, "INSERT INTO pokeruser (username, password) VALUES ('%s', '%s');", buf, context.hex_digest()); if (!dbase_->dbQuery(query)) { Sys_LogError("Query to create test player failed(2)."); return false; } } } return true; }
bool xeta::FileTransfer::test_chksum() const { MD5 tester; MD5::Sum result; int i = 0; while( true ) { ++i; if( tester.file( local_file.c_str(), result) ) break; if( i == 5 ) return false; } return result == checksum; }
void main() { HMODULE hVDLL; IBaseVerify* pCV; _NxModule_GetType NxModule_GetType; _NxVerify_GetInterface NxVerify_GetInterface; size_t cEncode_Id = 1; // _GetVersion pGetVersion; hVDLL = LoadLibrary("NxVerify.dll"); NxModule_GetType = (_NxModule_GetType)GetProcAddress(hVDLL, "NxModule_GetType"); NxVerify_GetInterface = (_NxVerify_GetInterface)GetProcAddress(hVDLL, "NxVerify_GetInterface"); pCV = NxVerify_GetInterface(); unsigned char buf[128]; ZeroMemory(buf, sizeof(buf)); //memcpy(buf, (const char*)"A", sizeof("A")); MD5 alg; alg.update(buf, sizeof(buf)); alg.finalize(); UI08 output[16]; unsigned int *p; p = (unsigned int *)alg.digest; for (int i = 0; i < 4; i++) { printf("0x%08x\n", *p); p++; } pCV->EncodeFunc(cEncode_Id, alg.digest, output); p = (unsigned int *)output; for (int i = 0; i < 4; i++) { printf("0x%08x\n", *p); p++; } getchar(); }
void TestShell::dumpImage(skia::PlatformCanvas* canvas) const { skia::BitmapPlatformDevice& device = static_cast<skia::BitmapPlatformDevice&>(canvas->getTopPlatformDevice()); const SkBitmap& sourceBitmap = device.accessBitmap(false); SkAutoLockPixels sourceBitmapLock(sourceBitmap); // Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want // to keep it. On Windows, the alpha channel is wrong since text/form control // drawing may have erased it in a few places. So on Windows we force it to // opaque and also don't write the alpha channel for the reference. Linux // doesn't have the wrong alpha like Windows, but we match Windows. #if OS(MAC_OS_X) bool discardTransparency = false; #else bool discardTransparency = true; device.makeOpaque(0, 0, sourceBitmap.width(), sourceBitmap.height()); #endif // Compute MD5 sum. MD5 digester; Vector<uint8_t, 16> digestValue; digester.addBytes(reinterpret_cast<const uint8_t*>(sourceBitmap.getPixels()), sourceBitmap.getSize()); digester.checksum(digestValue); string md5hash; md5hash.reserve(16 * 2); for (unsigned i = 0; i < 16; ++i) { char hex[3]; // Use "x", not "X". The string must be lowercased. sprintf(hex, "%02x", digestValue[i]); md5hash.append(hex); } // Only encode and dump the png if the hashes don't match. Encoding the image // is really expensive. if (md5hash.compare(m_params.pixelHash)) { std::vector<unsigned char> png; webkit_support::EncodeBGRAPNG( reinterpret_cast<const unsigned char*>(sourceBitmap.getPixels()), sourceBitmap.width(), sourceBitmap.height(), static_cast<int>(sourceBitmap.rowBytes()), discardTransparency, &png); m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), &png[0], png.size(), m_params.pixelFileName.c_str()); } else m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), 0, 0, m_params.pixelFileName.c_str()); }
/** * @param ignore_comma if true, then the comma is ignored, even though * it's a valid IGC character */ static void AppendIGCString(MD5 &md5, const char *s, bool ignore_comma) { while (*s != '\0') { const char ch = *s++; if (ignore_comma && ch == ',') continue; if (IsValidIGCChar(ch)) md5.Append(ch); } }
/** * Creates MD5 hash key from skeletons.xml info and COLLADA converter version, * used to invalidate cached .pmd/psas * * @param[out] hash resulting MD5 hash * @param[out] version version passed to CCacheLoader, used if code change should force * cache invalidation */ void PrepareCacheKey(MD5& hash, u32& version) { // Add converter version to the hash version = COLLADA_CONVERTER_VERSION; // Cache the skeleton files hash data if (m_skeletonHashInvalidated) { VfsPaths paths; if (vfs::GetPathnames(m_VFS, L"art/skeletons/", L"*.xml", paths) != INFO::OK) { LOGWARNING("Failed to load skeleton definitions"); return; } // Sort the paths to not invalidate the cache if mods are mounted in different order // (No need to stable_sort as the VFS gurantees that we have no duplicates) std::sort(paths.begin(), paths.end()); // We need two u64s per file m_skeletonHashes.clear(); m_skeletonHashes.reserve(paths.size()*2); CFileInfo fileInfo; for (const VfsPath& path : paths) { // This will cause an assertion failure if *it doesn't exist, // because fileinfo is not a NULL pointer, which is annoying but that // should never happen, unless there really is a problem if (m_VFS->GetFileInfo(path, &fileInfo) != INFO::OK) { LOGERROR("Failed to stat '%s' for DAE caching", path.string8()); } else { m_skeletonHashes.push_back((u64)fileInfo.MTime() & ~1); //skip lowest bit, since zip and FAT don't preserve it m_skeletonHashes.push_back((u64)fileInfo.Size()); } } // Check if we were able to load any skeleton files if (m_skeletonHashes.empty()) LOGERROR("Failed to stat any skeleton definitions for DAE caching"); // We can continue, something else will break if we try loading a skeletal model m_skeletonHashInvalidated = false; } for (const u64& h : m_skeletonHashes) hash.Update((const u8*)&h, sizeof(h)); }
bool AuthContext::SetHashFileList(const std::wstring &theCommunity, const HashFileList &theList) { AutoCrit aCrit(mDataCrit); AuthLoginCommunityData &aData = mCommunityMap[theCommunity]; aData.mSimpleHash.erase(); aData.mKeyedHashData.erase(); MD5 aSimpleHash; MD5 aHashSection; int curHashSectionPos = 0; HashFileList::const_iterator anItr = theList.begin(); while(anItr!=theList.end()) { FILE *aFile = fopen(anItr->c_str(),"rb"); if(aFile==NULL) return false; ++anItr; const unsigned int HASH_CHUNK_SIZE = 16384; char aFileBuf[HASH_CHUNK_SIZE]; while(!feof(aFile)) { int aNumRead = fread(aFileBuf,1,HASH_CHUNK_SIZE-curHashSectionPos,aFile); if(aNumRead>0) { curHashSectionPos+=aNumRead; aSimpleHash.Update(aFileBuf,aNumRead); aHashSection.Update(aFileBuf,aNumRead); unsigned char aHashSectionBuf[16]; if(curHashSectionPos==HASH_CHUNK_SIZE || (feof(aFile) && anItr==theList.end())) { curHashSectionPos = 0; aHashSection.Digest(aHashSectionBuf); aData.mKeyedHashData.append(aHashSectionBuf,16); aHashSection.Reset(); } } } fclose(aFile); } unsigned char aSimpleHashBuf[16]; aSimpleHash.Digest(aSimpleHashBuf); aData.mSimpleHash.assign(aSimpleHashBuf,16); return true; }
TEST( Utils, MD5 ) { MD5 checksum; // abc checksum.update("abc"); EXPECT_EQ( "900150983cd24fb0d6963f7d28e17f72", checksum.final_hex() ); // abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq checksum.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"); EXPECT_EQ( "8215ef0796a20bcaaae116d3876c664a", checksum.final_hex() ); // A million repetitions of 'a'. for (int i = 0; i < 1000000/200; ++i) { checksum.update( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); } EXPECT_EQ( "7707d6ae4e027c70eea2a935c2296f21", checksum.final_hex() ); // No string EXPECT_EQ( "d41d8cd98f00b204e9800998ecf8427e", checksum.final_hex()); // Empty string checksum.update(""); EXPECT_EQ( "d41d8cd98f00b204e9800998ecf8427e", checksum.final_hex()); // Two concurrent checksum calculations MD5 checksum1, checksum2; checksum1.update("abc"); EXPECT_EQ( "900150983cd24fb0d6963f7d28e17f72", checksum1.final_hex()); EXPECT_EQ( "d41d8cd98f00b204e9800998ecf8427e", checksum2.final_hex()); }
void output_directory( set< string >& file_names, const string& path_name, int level, ofstream& outf, bool use_zlib, gzFile& gzf ) #endif { string::size_type pos = path_name.find_last_of( '/' ); if( level > 1 && pos != string::npos && !g_output_directories.count( path_name.substr( 0, pos ) ) ) { #ifndef ZLIB_SUPPORT output_directory( file_names, path_name.substr( 0, pos ), level - 1, outf ); #else output_directory( file_names, path_name.substr( 0, pos ), level - 1, outf, use_zlib, gzf ); #endif } if( !file_names.count( path_name ) ) { string rel_path( "." ); string::size_type pos = path_name.find( '/' ); if( pos != string::npos ) rel_path += path_name.substr( pos ); string perms = file_perms( rel_path ); MD5 md5; md5.update( ( unsigned char* )perms.c_str( ), perms.length( ) ); md5.update( ( unsigned char* )path_name.c_str( ), path_name.length( ) ); md5.finalize( ); auto_ptr< char > ap_digest( md5.hex_digest( ) ); ostringstream osstr; osstr << "D " << level << ' ' << perms << ' ' << path_name << ' ' << ap_digest.get( ); g_md5.update( ( unsigned char* )ap_digest.get( ), 32 ); #ifndef ZLIB_SUPPORT outf << osstr.str( ) << '\n'; #else if( !use_zlib ) outf << osstr.str( ) << '\n'; else write_zlib_line( gzf, osstr.str( ) ); #endif file_names.insert( path_name ); } g_output_directories.insert( path_name ); }
void checkPass(char* hashFile, char* tempString, int myRank, char* type) { int i; bool foundPass = false; char str[SHA256_HASH_LENGTH+1]; char testHash[SHA256_HASH_LENGTH+1]; if (strcmp(type, "MD5") == 0) { sprintf(testHash, "%s", md5.digestString(tempString)); } else if (strcmp(type, "SHA1") == 0) { unsigned char binaryHash[SHA_DIGEST_LENGTH]; unsigned char* sha1String = (unsigned char*)tempString; SHA1(sha1String, strlen(tempString), binaryHash); for (i = 0; i < SHA_DIGEST_LENGTH; i++) sprintf(testHash+2*i, "%02x", binaryHash[i]); } else if (strcmp(type, "SHA256") == 0) { unsigned char binaryHash[SHA256_DIGEST_LENGTH]; unsigned char* sha256String = (unsigned char*)tempString; SHA256(sha256String, strlen(tempString), binaryHash); for (i = 0; i < SHA256_DIGEST_LENGTH; i++) sprintf(testHash+2*i, "%02x", binaryHash[i]); } // printf("Proc %d: %s\n", myRank, tempString); // Debugging info FILE* pFile; pFile = fopen (hashFile,"r"); if (pFile == NULL) { perror ("Error opening file, aborting\n"); MPI_Finalize(); exit(-3); } while (fscanf (pFile, "%s", str) != EOF) { foundPass = (strcmp(testHash, str) == 0); if (foundPass) { printf("%s, %s\n", tempString, testHash); } } fclose (pFile); }
VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initialHash, u32 version) { CFileInfo fileInfo; if (m_VFS->GetFileInfo(sourcePath, &fileInfo) < 0) { debug_warn(L"source file disappeared"); // this should never happen return VfsPath(); } u64 mtime = (u64)fileInfo.MTime() & ~1; // skip lowest bit, since zip and FAT don't preserve it u64 size = (u64)fileInfo.Size(); // Construct a hash of the file data and settings. MD5 hash = initialHash; hash.Update((const u8*)&mtime, sizeof(mtime)); hash.Update((const u8*)&size, sizeof(size)); hash.Update((const u8*)&version, sizeof(version)); // these are local cached files, so we don't care about endianness etc // Use a short prefix of the full hash (we don't need high collision-resistance), // converted to hex u8 digest[MD5::DIGESTSIZE]; hash.Final(digest); std::wstringstream digestPrefix; digestPrefix << std::hex; for (size_t i = 0; i < 8; ++i) digestPrefix << std::setfill(L'0') << std::setw(2) << (int)digest[i]; // Get the mod path OsPath path; m_VFS->GetRealPath(sourcePath, path); // Construct the final path return VfsPath("cache") / path_name_only(path.BeforeCommon(sourcePath).Parent().string().c_str()) / sourcePath.ChangeExtension(sourcePath.Extension().string() + L"." + digestPrefix.str() + m_FileExtension); }
static void md5_block(MD5& md5, const Pel* plane, unsigned n) { /* create a 64 byte buffer for packing Pel's into */ unsigned char buf[64/OUTPUT_BITDEPTH_DIV8][OUTPUT_BITDEPTH_DIV8]; for (unsigned i = 0; i < n; i++) { Pel pel = plane[i]; /* perform bitdepth and endian conversion */ for (unsigned d = 0; d < OUTPUT_BITDEPTH_DIV8; d++) { buf[i][d] = pel >> (d*8); } } md5.update((unsigned char*)buf, n * OUTPUT_BITDEPTH_DIV8); }
void CTextureConverter::Settings::Hash(MD5& hash) { hash.Update((const u8*)&format, sizeof(format)); hash.Update((const u8*)&mipmap, sizeof(mipmap)); hash.Update((const u8*)&normal, sizeof(normal)); hash.Update((const u8*)&alpha, sizeof(alpha)); hash.Update((const u8*)&filter, sizeof(filter)); hash.Update((const u8*)&kaiserWidth, sizeof(kaiserWidth)); hash.Update((const u8*)&kaiserAlpha, sizeof(kaiserAlpha)); hash.Update((const u8*)&kaiserStretch, sizeof(kaiserStretch)); }
void checkPass(char* hash, char* tempString) { char testHash[HASH_LENGTH]; int i; bool foundPass = false; sprintf(testHash, "%s", md5.digestString(tempString)); // printf("%s\n", tempString); for (i = 0; i < HASH_LENGTH; i++) {// Checks if the hashes match if (testHash[i] != hash[i]) { foundPass = false; break; } else { foundPass = true; } } if (foundPass) { printf("The password is %s\n", tempString); exit(0); } }