greglebreton 4e8a693745
Some checks failed
continuous-integration/drone/push Build is failing
add garagenum exp + maj url site projets
2023-01-08 16:50:31 +01:00

21 lines
438 B
JavaScript

// @flow strict-local
import crypto from 'crypto';
// $FlowFixMe
type Hashable = Object;
export default function objectHash(object: Hashable): string {
let hash = crypto.createHash('md5');
for (let key of Object.keys(object).sort()) {
let val = object[key];
if (typeof val === 'object' && val) {
hash.update(key + objectHash(val));
} else {
hash.update(key + val);
}
}
return hash.digest('hex');
}