bool Canvas::getDigest(Digest& digest) { // we don't have a digest if the image is uninitialized if (!m_pBMIH) return false; // read data from DIB int nSize = m_nLineLength * m_nHeight; BYTE* pData = new BYTE[nSize]; memset(pData, 0, nSize); if (GetDIBits(m_hDC, m_hBmp, 0, m_nHeight, pData, reinterpret_cast<BITMAPINFO*>(m_pBMIH), DIB_RGB_COLORS) != m_nHeight) { delete[] pData; return false; } // apply transparency, if any updateTrans(pData); // calculate hash mir_sha1_hash(pData, nSize, digest.m_Digest); delete[] pData; return true; }
char *gg_avatarhash(char *param) { mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE]; char *result; int i; if (param == NULL || (result = (char *)mir_alloc(MIR_SHA1_HASH_SIZE * 2 + 1)) == NULL) return NULL; mir_sha1_hash(param, (int)strlen(param), digest); for (i = 0; i < MIR_SHA1_HASH_SIZE; i++) sprintf(result + (i<<1), "%02x", digest[i]); return result; }