mirror of
https://github.com/holub/mame
synced 2025-04-22 08:22:15 +03:00
split was using sha1.h directly - fix that (nw)
This commit is contained in:
parent
c2ca7ea90c
commit
2add7c158c
@ -45,7 +45,7 @@ constexpr uint32_t sha1_rol(uint32_t x, unsigned n)
|
||||
return (x << n) | (x >> (32 - n));
|
||||
}
|
||||
|
||||
uint32_t sha1_b(uint32_t *data, unsigned i)
|
||||
inline uint32_t sha1_b(uint32_t *data, unsigned i)
|
||||
{
|
||||
uint32_t r = data[(i + 13) & 15U];
|
||||
r ^= data[(i + 8) & 15U];
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
****************************************************************************/
|
||||
#include <stdio.h> // must be stdio.h and here otherwise issues with I64FMT in MINGW
|
||||
#include <cassert>
|
||||
|
||||
#include "osdcore.h"
|
||||
#include "corefile.h"
|
||||
@ -15,17 +14,17 @@
|
||||
#include "avhuff.h"
|
||||
#include "bitmap.h"
|
||||
#include "md5.h"
|
||||
#include "sha1.h"
|
||||
#include "hashing.h"
|
||||
#include "vbiparse.h"
|
||||
#include <cstdarg>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cctype>
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
|
@ -8,17 +8,19 @@
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include "corefile.h"
|
||||
#include "corestr.h"
|
||||
#include "hashing.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
#include "corefile.h"
|
||||
#include "corestr.h"
|
||||
#include "sha1.h"
|
||||
|
||||
#define DEFAULT_SPLIT_SIZE 100
|
||||
#define MAX_PARTS 1000
|
||||
#define SHA1_DIGEST_SIZE 20
|
||||
|
||||
|
||||
|
||||
@ -34,22 +36,17 @@
|
||||
|
||||
static void compute_hash_as_string(std::string &buffer, void *data, uint32_t length)
|
||||
{
|
||||
char expanded[SHA1_DIGEST_SIZE * 2];
|
||||
uint8_t sha1digest[SHA1_DIGEST_SIZE];
|
||||
struct sha1_ctx sha1;
|
||||
int ch;
|
||||
|
||||
// compute the SHA1
|
||||
sha1_init(&sha1);
|
||||
sha1_update(&sha1, length, (const uint8_t *)data);
|
||||
sha1_final(&sha1);
|
||||
sha1_digest(&sha1, sizeof(sha1digest), sha1digest);
|
||||
util::sha1_creator sha1;
|
||||
sha1.append(data, length);
|
||||
const util::sha1_t sha1digest = sha1.finish();
|
||||
|
||||
// expand the digest to a string
|
||||
for (ch = 0; ch < SHA1_DIGEST_SIZE; ch++)
|
||||
char expanded[sizeof(sha1digest.m_raw) * 2];
|
||||
for (int ch = 0; ch < sizeof(sha1digest.m_raw); ch++)
|
||||
{
|
||||
expanded[ch * 2 + 0] = "0123456789ABCDEF"[sha1digest[ch] >> 4];
|
||||
expanded[ch * 2 + 1] = "0123456789ABCDEF"[sha1digest[ch] & 15];
|
||||
expanded[ch * 2 + 0] = "0123456789ABCDEF"[sha1digest.m_raw[ch] >> 4];
|
||||
expanded[ch * 2 + 1] = "0123456789ABCDEF"[sha1digest.m_raw[ch] & 15];
|
||||
}
|
||||
|
||||
// copy it to the buffer
|
||||
|
Loading…
Reference in New Issue
Block a user