define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfDigestInformation = (function () {
function _PdfDigestInformation(algorithm, digest) {
this._algorithm = algorithm;
this._digest = digest;
}
_PdfDigestInformation.prototype._getUniqueEncoded = function () {
var algorithmBytes = this._algorithm._getEncoded();
var digestBytes = this._digest;
var algorithmLength = algorithmBytes.length;
var digestLength = digestBytes.length;
var contentLength = algorithmLength + digestLength + 1 + this._getLengthBytes(digestLength).length;
var result = [];
result.push(0x30);
var lengthBytes = this._getLengthBytes(contentLength);
if (lengthBytes.length === 1) {
result.push(lengthBytes[0]);
}
else {
result.push(0x80 | (lengthBytes.length - 1));
for (var i = 1; i < lengthBytes.length; i++) {
result.push(lengthBytes[i]);
}
}
result.push.apply(result, Array.from(algorithmBytes));
result.push(0x04);
var digestLengthBytes = this._getLengthBytes(digestLength);
if (digestLengthBytes.length === 1) {
result.push(digestLengthBytes[0]);
}
else {
result.push(0x80 | (digestLengthBytes.length - 1));
for (var i = 1; i < digestLengthBytes.length; i++) {
result.push(digestLengthBytes[i]);
}
}
result.push.apply(result, Array.from(digestBytes));
return new Uint8Array(result);
};
_PdfDigestInformation.prototype._getLengthBytes = function (length) {
if (length < 128) {
return [length];
}
var bytes = [];
var tempLength = length;
while (tempLength > 0) {
bytes.unshift(tempLength & 0xFF);
tempLength = Math.floor(tempLength / 256);
}
return [0x80 | bytes.length].concat(bytes);
};
return _PdfDigestInformation;
}());
exports._PdfDigestInformation = _PdfDigestInformation;
});
|