Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:43:57+00:00 2026-06-14T06:43:57+00:00

This is a design question, I am going to try to narrow it down

  • 0

This is a design question, I am going to try to narrow it down as much as possible to avoid flagging it as open-ended.

Problem

Need an effective way to design a class or two that hold the same data, but one has the data fields as encrypted strings, and the second have them as either decrypted strings or ints. I receive the data encrypted, I decrypt it once and allow my application to use the decrypted version.

What I have

I came up with different solutions, but not satifisfied with any of them. This is what I tried:

  1. One class with boolean flag `encrypted`, initially set to be `true` and then unset after the data is decrypted. The cons, the same fields are multi-used, sounds unsafe even though there is a private flag; another con, some fields are of different type once decrypted, say an ID, Ideally I want the decrypted version to be in the correct final type, so that wont work with adding new fields to the same class, which makes it messy and will complicate other tasks such as data binding, etc
  2. Thought about decorator pattern, but the way it works is to have the decorator and the subject class implement the same interface, but again return types will vary after decryption
  3. thought about having 2 classes, one for the decrypted version of the class and other for the encrypted. however, code reuses is abandoned in this approach, to fix that thought about having the decrypted version extend the encrypted one and reuse the getters of the encrypted fields that don’t change type after decryption, but fields that change type cannot be overriden
  4. thought about leaving data in String format even after decryption, and convert to integers outside of the class, but this is redundant and will clutter my code with silly code fragments whenever I need to use the integer fields of the class

Any ideas for how to go about solving this design problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:43:58+00:00Added an answer on June 14, 2026 at 6:43 am

    The best way to encrypt fields is to simply serialize the object instance and encrypt the resulting stream. For getting the decrypted object instance, simply decrypt the stream and deserialize the object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a design question: when do I need to create/use a static method
This is more of a PHP design question. Basically, I'm going to have a
This is a design question. I find myself going back and forth between two
This is a design question, I guess there going to be several suggestions (I
This is a design question, I noticed that by time by LINQ-to-SQL Context gets
This is a design question. I'm trying to decide between 2 implementations. In order
This is more of a design question. I have a template class, and I
This is a design principle question for classes dealing with mathematical/physical equations where the
This is a practical Domain Driven Design question: Conceptually, I think I get Aggregate
This should be a very basic design question, but for some reason it doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.