feat(kik): Implement document ID encryption for KİK v2 API

Reverse engineered the AES-256-CBC encryption used by KİK's Angular web
application to generate document URL hashes from numeric IDs.

Key findings:
- Algorithm: AES-256-CBC with PKCS7 padding
- Key location: ekapv2.kik.gov.tr module 21554 (environment config)
- Output format: IV (16 bytes hex) + Ciphertext (16 bytes hex) = 64 chars

Changes:
- Added encrypt_document_id() static method to KikV2ApiClient
- Updated get_document_markdown() to auto-encrypt numeric gundemMaddesiId
- Added cryptography>=44.0.0 dependency for AES encryption
- Both primary and fallback URL paths now support encryption

This enables direct document retrieval from numeric search result IDs
without requiring the pre-encrypted hash from the web interface.
This commit is contained in:
saidsurucu
2025-12-04 15:17:13 +03:00
parent 91ad04cf09
commit a2b50951e9
3 changed files with 84 additions and 6 deletions
+1
View File
@@ -29,6 +29,7 @@ dependencies = [
"fastmcp>=2.10.5",
"pypdf>=5.5.0",
"fastapi>=0.115.14",
"cryptography>=44.0.0",
]
[project.optional-dependencies]