@contract-js/pdf-utils
v1.1.0
Published
[//]: # (@contract-js/pdf-utils - PDF Hash Utilities)
Maintainers
Readme
🔍 @contract-js/pdf-utils
PDF Hash Generation and Comparison
Utility functions for PDF hash generation and comparison in contract-js.
🎯 Purpose
Provide utility functions for generating cryptographic hashes from PDF documents and comparing them to detect changes.
✨ Features
- PDF Hashing – Generate cryptographic hashes for PDF documents
- Hash Comparison – Compare PDF hashes to detect changes
- Multiple Algorithms – Support for various hash algorithms
🚀 Usage
Generate PDF Hash
import { getPdfHash } from '@contract-js/pdf-utils';
const pdfBuffer = fs.readFileSync('contract.pdf');
const hash = getPdfHash(pdfBuffer, {
hashAlgorithm: 'sha256'
});
console.log('PDF Hash:', hash);Compare PDF Hashes
import { comparePdfHash } from '@contract-js/pdf-utils';
const isIdentical = comparePdfHash(originalHash, currentHash);
console.log('PDFs identical:', isIdentical);📦 Installation
# npm
npm install @contract-js/pdf-utils
# pnpm (recommended)
pnpm add @contract-js/pdf-utils
# yarn
yarn add @contract-js/pdf-utils📋 API Reference
| Function | Description | Parameters |
|----------|-------------|------------|
| getPdfHash | Generate hash from PDF buffer | pdfBuffer, options |
| comparePdfHash | Compare two PDF hashes | hash1, hash2 |
🔒 Supported Algorithms
- SHA-1 – 160-bit hash (fast but less secure)
- SHA-256 – 256-bit hash (recommended)
- SHA-384 – 384-bit hash (high security)
- SHA-512 – 512-bit hash (maximum security)
📝 License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © Jeonhui
