Use hash API instead of commands (#2756)

This commit is contained in:
Anton Kochkov 2021-09-16 13:39:05 +08:00 committed by GitHub
parent 5595193b70
commit 6d2b3a2f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -244,16 +244,27 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
: "");
} else {
// Fill the information tab hashes and entropy
ui->bytesMD5->setText(
Core()->cmdRawAt(QString("ph md5 %1").arg(size), start_address).trimmed());
ui->bytesSHA1->setText(
Core()->cmdRawAt(QString("ph sha1 %1").arg(size), start_address).trimmed());
ui->bytesSHA256->setText(
Core()->cmdRawAt(QString("ph sha256 %1").arg(size), start_address).trimmed());
ui->bytesCRC32->setText(
Core()->cmdRawAt(QString("ph crc32 %1").arg(size), start_address).trimmed());
ui->bytesEntropy->setText(
Core()->cmdRawAt(QString("ph entropy %1").arg(size), start_address).trimmed());
RzMsgDigestSize digest_size = 0;
RzCoreLocked core(Core());
ut64 old_offset = core->offset;
rz_core_seek(core, start_address, true);
ut8 *block = core->block;
char *digest = rz_msg_digest_calculate_small_block_string("md5", block, size, &digest_size, false);
ui->bytesMD5->setText(QString(digest));
free(digest);
digest = rz_msg_digest_calculate_small_block_string("sha1", block, size, &digest_size, false);
ui->bytesSHA1->setText(QString(digest));
free(digest);
digest = rz_msg_digest_calculate_small_block_string("sha256", block, size, &digest_size, false);
ui->bytesSHA256->setText(QString(digest));
free(digest);
digest = rz_msg_digest_calculate_small_block_string("crc32", block, size, &digest_size, false);
ui->bytesCRC32->setText(QString(digest));
free(digest);
digest = rz_msg_digest_calculate_small_block_string("entropy", block, size, &digest_size, false);
ui->bytesEntropy->setText(QString(digest));
free(digest);
rz_core_seek(core, old_offset, true);
ui->bytesMD5->setCursorPosition(0);
ui->bytesSHA1->setCursorPosition(0);
ui->bytesSHA256->setCursorPosition(0);