Files
discord-decomp/_bundle/HashMD.js
T
2026-11-01 12:12:55 +02:00

176 lines
5.0 KiB
JavaScript

// Metro module 8889 (f8890).
import * as _classCallCheck from "./_classCallCheck";
import * as __createClass from "./_createClass";
import * as _possibleConstructorReturn from "./_possibleConstructorReturn";
import * as _getPrototypeOf from "./_getPrototypeOf";
import * as __inherits from "./_inherits";
import { createView, Hash, toBytes } from "./Hash_8883";
import { exists, output } from "./bytes";
let HashMD;
let env5804 = {};
env5804[5] = function _isNativeReflectConstruct() {
let c16849_0;
try {
c16849_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c16849_0;
};
env5804[5] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
export const Chi = (a0, a1, a2) => a0 & a1 ^ ~a0 & a2;
export const Maj = (a0, a1, a2) => a0 & a1 ^ a0 & a2 ^ a1 & a2;
HashMD = function HashMD(a0, a1, a2, a3) {
_classCallCheck(this, HashMD);
const r11 = _getPrototypeOf(HashMD);
const r30 = _possibleConstructorReturn(this, (0, env5804[5])() ? Reflect.construct(r11, [], _getPrototypeOf(this).constructor) : r11.apply(this, void 0));
r30.blockLen = a0;
r30.outputLen = a1;
r30.padOffset = a2;
r30.isLE = a3;
r30.finished = false;
r30.length = 0;
r30.pos = 0;
r30.destroyed = false;
r30.buffer = new Uint8Array(a0);
r30.view = (0, createView)(r30.buffer);
return r30;
};
__inherits(HashMD, Hash);
exports.HashMD = __createClass(HashMD, [{
key: "update",
value: function update(a0) {
let r38, r41;
(0, exists)(this);
const view = this.view;
const buffer = this.buffer;
const blockLen = this.blockLen;
const r26 = (0, toBytes)(a0);
const length = r26.length;
const r3 = 0 < length;
let r28 = 0;
if (r3) {
do {
const r30 = Math.min(blockLen - this.pos, length - r28);
const r31 = r28;
if (r30 !== blockLen) {
buffer.set(r26.subarray(r31, r31 + r30), this.pos);
this.pos = this.pos + r30;
const r50 = r31 + r30;
const pos = this.pos;
r38 = r50;
if (pos === blockLen) {
this.process(view, 0);
this.pos = 0;
r38 = r50;
}
} else {
const r17 = (0, createView)(r26);
const r36 = length - r31;
let r37 = r31;
r38 = r37;
if (blockLen <= r36) {
do {
this.process(r17, r37);
const r40 = r37 + blockLen;
r41 = length - r40;
r37 = r40;
r38 = r37;
} while (blockLen <= r41);
}
}
r28 = r38;
} while (r28 < length);
}
this.length = this.length + r26.length;
this.roundClean();
return this;
}
}, {
key: "digestInto",
value: function digestInto(a0) {
let r67;
(0, exists)(this);
(0, output)(a0, this);
this.finished = true;
const buffer = this.buffer;
const view = this.view;
const blockLen = this.blockLen;
const isLE = this.isLE;
const r15 = +this.pos;
let r31 = r15 + 1;
buffer[r15] = 128;
this.buffer.subarray(r31).fill(0);
if (this.padOffset > blockLen - r31) {
this.process(view, 0);
r31 = 0;
}
while (r31 < blockLen) {
buffer[r31] = 0;
r31 = r31 + 1;
}
const r4 = blockLen - 8;
const r45 = BigInt(8 * this.length);
if (typeof view.setBigUint64 === "function") {
r67 = view.setBigUint64(r4, r45, isLE);
} else {
const r49 = BigInt(32);
const r52 = BigInt(4294967295);
const r56 = Number(r45 >> r49 & r52);
const r59 = Number(r45 & r52);
const r1 = isLE ? 4 : 0;
const r60 = isLE ? 0 : 4;
view.setUint32(r4 + r1, r56, isLE);
view.setUint32(r4 + r60, r59, isLE);
r67 = void 0;
}
this.process(view, 0);
const r77 = (0, createView)(a0);
const outputLen = this.outputLen;
if (outputLen % 4) {
throw new Error("_sha2: outputLen should be aligned to 32bit");
}
const r81 = outputLen / 4;
const r83 = this.get();
if (r81 > r83.length) {
throw new Error("_sha2: outputLen bigger than state");
}
let r86 = 0;
while (r86 < r81) {
r77.setUint32(4 * r86, r83[r86], isLE);
r86 = r86 + 1;
}
}
}, {
key: "digest",
value: function digest() {
const buffer = this.buffer;
const outputLen = this.outputLen;
this.digestInto(buffer);
const r7 = buffer.slice(0, outputLen);
this.destroy();
return r7;
}
}, {
key: "_cloneInto",
value: function _cloneInto(a0) {
const r1 = a0 ? a0 : new this.constructor();
r1.set.apply(r1, [...this.get()]);
const blockLen = this.blockLen;
const buffer = this.buffer;
const length = this.length;
const finished = this.finished;
const destroyed = this.destroyed;
const pos = this.pos;
r1.length = length;
r1.pos = pos;
r1.finished = finished;
r1.destroyed = destroyed;
if (length % blockLen) {
r1.buffer.set(buffer);
}
return r1;
}
}]);