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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:05:36+00:00 2026-05-18T10:05:36+00:00

I have created a SecretkeySpec object wich contains a 128 bit key. I would

  • 0

I have created a SecretkeySpec object wich contains a 128 bit key.
I would like to have this key in a String(this string needs to be put back in to the original key later), so i use Base64 encoding.

This is how my key looks in raw format from the byte array into chars:

*P??? ?ukL|?~

So I take the bytes and encode it like this.

byte[] okay = Base64.encode(eF.getSpec().getEncoded());

Now when i translate it into chars i get:

S2xEa3Ara0o5blVGYTB3WkRIeUZmZz09DQo=

Now i want to have my key back restored to it’s original format from the base64 encoded array.

String dkey = "S2xEa3Ara0o5blVGYTB3WkRIeUZmZz09DQo=";

byte[] key = null;
key = dKey.getBytes();
key = Base64.decode(key);

Now when i check the result i get:

DKlDkp+kJ9nUFa0wZHyFfg==

instead of:

*P??? ?ukL|?~ 

As you can see this is not the result i hoped to see.
I surely made a novice mistake, and forgive me for that but i am relativaly new to programming.
I would appreciate it if someone could give me a working example of transforming
the 128 bit key to and from readable format, and perhaps an explanation where i went wrong with thinking.

And i apologize for any spelling mistakes, English is not my native language.

Thanks in advance

  • 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-05-18T10:05:37+00:00Added an answer on May 18, 2026 at 10:05 am
    S2xEa3Ara0o5blVGYTB3WkRIeUZmZz09DQo=
    

    decodes to

    KlDkp+kJ9nUFa0wZDHyFfg==.
    

    Is the extra D at the beginning a copy and paste error?

    KlDkp+kJ9nUFa0wZDHyFfg== 
    

    in turn is a valid base64 string that decodes to some binary data. So it seems that you are doing the encoding twice.

    Now when i translate it into chars i get

    How exactly are you doing that? Is there another base64 encoding involved in that step?

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

Sidebar

Related Questions

I have created dictionary object Dictionary<string, List<string>> dictionary = new Dictionary<string,List<string>>(); I want to
I have created a pygame, the object of the game is to avoid the
I have created a simple facebook login page at: http://bit.ly/Ims3U6 In the app settings:
I have created the following string field for indexing. <fieldType name=short_text_for_sort class=solr.StrField omitNorms=true sortMissingLast=true
I have created a bar to appear over the keyboard for next/previous/done like the
have created REST service using servicestack and in post request I have return object
I have created a windows service which is set to start automatically. This service
I have created a foreign key (in SQL Server) by: alter table company add
I have created a facebook apps. Works fine for me. It contains canvas url,
I have created a very simple app to invite friends. This is my code:

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.