Skip to content

Add DICOM runtime key parameters#250

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-249
Draft

Add DICOM runtime key parameters#250
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-249

Conversation

Copy link
Copy Markdown

Copilot AI commented Aug 14, 2025

This PR implements the ability to specify key values as optional parameters when de-identifying a specific data set in AnonymizerEngine.AnonymizeDataset, allowing runtime override of configuration-based keys.

Changes Made

New RuntimeKeySettings Class: Added a new class to hold optional runtime key values for cryptoHashKey, dateShiftKey, and encryptKey that can override configuration defaults.

Enhanced AnonymizerEngine: Added a new overload AnonymizeDataset(DicomDataset dataset, RuntimeKeySettings runtimeKeySettings) while maintaining full backward compatibility with the existing AnonymizeDataset(DicomDataset dataset) method.

Updated Processors: Modified CryptoHashProcessor, DateShiftProcessor, and EncryptProcessor to use runtime keys when available, falling back to configuration keys when not provided.

ProcessContext Enhancement: Extended ProcessContext to pass runtime keys to processors through the anonymization pipeline.

Usage Example

var engine = new AnonymizerEngine("configuration.json");

// Existing behavior - uses configuration keys
engine.AnonymizeDataset(dataset);

// New functionality - uses runtime keys
var runtimeKeys = new RuntimeKeySettings 
{ 
    CryptoHashKey = "runtime-crypto-key",
    DateShiftKey = "runtime-date-key",
    EncryptKey = "runtime-encrypt-key-12345678901234567890123456"
};
engine.AnonymizeDataset(dataset, runtimeKeys);

Benefits

  • Per-dataset anonymization: Different datasets can use different keys while sharing the same configuration
  • Dynamic key generation: Keys can be generated programmatically based on external factors
  • Enhanced security: Keys can be managed separately from configuration files
  • Zero breaking changes: All existing functionality is preserved

Testing

Added comprehensive unit tests covering:

  • Different runtime keys producing different results
  • Same runtime keys producing consistent results
  • Fallback to configuration keys when no runtime key provided
  • DateShift processor with runtime keys

All existing tests continue to pass, demonstrating no regressions were introduced.

Fixes #249.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Copy Markdown
Author

Copilot AI commented Aug 14, 2025

@jovinson-ms 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits August 15, 2025 00:00
Co-authored-by: jovinson-ms <88204686+jovinson-ms@users.noreply.github.com>
Co-authored-by: jovinson-ms <88204686+jovinson-ms@users.noreply.github.com>
Copilot AI changed the title [WIP] Add DICOM seed runtime parameters Add DICOM seed runtime parameters Aug 15, 2025
Copilot AI requested a review from jovinson-ms August 15, 2025 00:02
@jovinson-ms
Copy link
Copy Markdown
Collaborator

@copilot can you change all references to "seed" to "key" to match the terminology in the existing code? And also move the documentation from a separate file to be a section in the main dicom documentation md file.

…entation to main docs

Co-authored-by: jovinson-ms <88204686+jovinson-ms@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Aug 15, 2025

@copilot can you change all references to "seed" to "key" to match the terminology in the existing code? And also move the documentation from a separate file to be a section in the main dicom document...

I've updated all references from "seed" to "key" to match the existing codebase terminology and moved the documentation from the separate file to the main DICOM documentation file as requested. Changes include:

Terminology Updates:

  • Renamed RuntimeSeedSettings to RuntimeKeySettings
  • Updated all method parameters, properties, and comments to use "key" instead of "seed"
  • Updated test class and method names accordingly

Documentation Consolidation:

  • Moved content from DICOM/RuntimeSeedExample.md to docs/DICOM-anonymization.md as a new "Runtime Key Parameters" section
  • Updated all documentation examples to use "key" terminology
  • Removed the separate documentation file

All tests pass and the code now uses consistent terminology with the rest of the codebase.

Commit: 3a5c1d7

Copilot AI changed the title Add DICOM seed runtime parameters Add DICOM runtime key parameters Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add DICOM seed runtime parameters

2 participants