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 8397847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:53:28+00:00 2026-06-09T20:53:28+00:00

String secret=foo; WhatILookFor.securelyWipe(secret); And I need to know that it will not be removed

  • 0
String secret="foo";
WhatILookFor.securelyWipe(secret);

And I need to know that it will not be removed by java optimizer.

  • 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-09T20:53:29+00:00Added an answer on June 9, 2026 at 8:53 pm

    A String cannot be "wiped". It is immutable, and short of some really dirty and dangerous tricks (using reflection, for example) you cannot alter that.

    So the safest solution is to not put the data into a String in the first place. Use a StringBuilder or an array of characters instead, or some other representation that is not immutable. (And then clear it when you are done. And don’t use toString() etc on the StringBuilder or you have created the String you were trying to avoid.)

    Of course, the "safest" solution is rather impractical. Many Java SE and 3rd party APIs require or return text data to be provided as String objects.


    For the record, there are a couple of ways that you can change the contents of a String’s backing array. For example, you can use reflection to fish out a reference to the String object’s backing array, and overwrite its contents. However, this involves doing things that the JLS states have unspecified behavior so you cannot guarantee that the optimizer won’t do something unexpected. And the code to do this will be non-portable, since it depends on internal details of String that have changed over time and may change again.


    My personal take on this is that you are better off locking down your application platform so that unauthorized people can’t gain access to the memory / memory dump in the first place. After all, if the platform is not properly secured, the "bad guys" may be able to get hold of the string contents before you erase it. Steps like this might be warranted for small amounts of security critical state, but if you’ve got a lot of "confidential" information to process, it is going to be a major hassle to not be able to use normal strings and string handling.

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

Sidebar

Related Questions

EDIT: I need to generate a string of 7 chars that is based on
In my Java code I have the following snippet : String secret = secret;
When using the OAuth protocol, you need a secret string obtained from the service
I'm making a simple tool that will get a string of MySQL commands and
In secret_token.rb under rails initializers, there is secret token appearing as a string of
I need to connect and authenticate users from java desk top application , i
I am building a console app that will publish streams to a page's wall.
This is a brainstorming question about what's possible in Java (or not). I want
I get the error Requrest token or token secret not set in server reply.
Let's say I have an interface: public interface Foo{ String bar(int baz); } Now

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.