0

At this moment I've an application built in Spring (Java 11) and I'm trying to figure out a better way to cypher the data that is stored in MongoDB.

Currently I've a method to cypher the user's password:

@Bean
public PasswordEncoder encoder() {
    return new BCryptPasswordEncoder();
}

user.setPassword(passwordEncoder.encode(password));

It works fine, but since I'm getting worried about data leaks I'll encode the whole user's personal data like name, address and email...

The main question I want to ask is: There's a better way to make this effient? Or the best way is to use the same code above to the trick?

PS: I've no problems to add new modules from Spring, like Security or Cloud.

3
  • 1
    You are aware that the entire point of password encoders like BCrypt is that you can't get the original values back out? Commented Oct 25, 2020 at 2:28
  • 1
    If you Store the Data encrypted in your dB How should the search part work? You would have to do a lot of Computing for every search which makes no sense. Encode your backups and use database auth with strict permissions and you are good Commented Oct 25, 2020 at 5:17
  • @AllesFuerDenDackel Now that you've pointed it out I've realised that it was a mistake to think about encode all the data. Thank you for pointing it out. If you could please set it as an answer so I can vote it. Commented Oct 25, 2020 at 20:22

1 Answer 1

1

If you Store the Data encrypted in your dB How should the search part work? You would have to do a lot of Computing for every search which makes no sense. Encode your backups and use database auth with strict permissions and you are good.

Glad this helped:)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.