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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:28:46+00:00 2026-06-06T19:28:46+00:00

I import an XML file as a byte array to the project RandomAccessFile rnd

  • 0

I import an XML file as a byte array to the project

RandomAccessFile rnd = new RandomAccessFile(filePath, "r");
byte[] fileData = new byte[(int) rnd.length()];
rnd.read(fileData);

I encrypted the array using java.crypto

Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");

byte[] encypted = new byte[cipher.getOutputSize(fileData.length)];
int len = cipher.update(fileData, 0, fileData.length, encypted, 0);
len += cipher.doFinal(encypted, len);

When I decrypt the byte array and print it using

System.out.println(new String(decrypted, "UTF-8"));

I got the XML file but there were some unkown characters at the end (they are only at the end). Is there any way I can remove this?

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-06-06T19:28:47+00:00Added an answer on June 6, 2026 at 7:28 pm

    see a similar question here, the answer though is what might be very relavent to your situation:

    1.If you don’t know what padding was used to encrypt, then decrypt with
    ‘no padding’ set. That will decrypt everything, including the padding,
    and won’t throw an error because of mismatched padding.

    2.When you have decrypted the cyphertext, have a look at the last block
    of the output and see what padding was used. Different paddings leave
    different byte patterns, so it is usually easy enough to tell.

    3.Set your decryption method to expect the correct type of padding, and
    it will be automatically removed for you.

    and incase this is relavant to you here is a link on padding patterns etc: Padding Wikipedia

    This over here is also a very good tutorial for encrypting using DES: http://www.exampledepot.com/egs/javax.crypto/desstring.html and here is for PBE in DES:
    PBE with HMAC(SHA1) and DES(EDE)

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

Sidebar

Related Questions

Given the following: >>> from lxml import etree >>> contents=open('file.xml').read() >>> node=etree.fromstring(contents) How would
I am new to Wordpress, tried couple of plugins to import xml file. This
I am trying to read a element form a xml file to add new
the task I want to achieve is import XML file into SQL Server. Once
I'm trying to import an XML file that contains a list of points for
I'm trying to import an xml file into vb.net XmlDocument but am getting the
I want to read simple excel xml file to dictionary. I have tried to
I want to import an XML file from polarpersonaltrainer.com that stores heartrate data into
I'm just learning scala and im trying to import an XML file to a
I need to read a XML file returned from a web service. I was

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.