Why linebreak when i write to file???

When my encryption program returns the encrypted string and I write that string to a file, it producces a linebreak if my string is to long?? why? can someone please help me. I can't decrypt my file cause i read each line and decrypt it seperate.
the code:
public class DesEncrypter {
Cipher ecipher;
Cipher dcipher;
// 8-byte Salt
byte[] salt = {
(byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
(byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
// Iteration count
int iterationCount = 19;
DesEncrypter(String passPhrase) {
try {
// Create the key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
// Create the ciphers
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
} catch (java.security.spec.InvalidKeySpecException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
public String encrypt(String str) {
try {
// Encode the string into bytes using utf-8
byte[] utf8 = str.getBytes("UTF8");
// Encrypt
byte[] enc = ecipher.doFinal(utf8);
// Encode bytes to base64 to get a string
return new sun.misc.BASE64Encoder().encode(enc);
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
} catch (java.io.IOException e) {
return null;
public String decrypt(String str) {
try {
// Decode base64 to get bytes
byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
// Decrypt
byte[] utf8 = dcipher.doFinal(dec);
// Decode using utf-8
return new String(utf8, "UTF8");
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
} catch (java.io.IOException e) {
return null;

Hi,
The Base 64 encoder breaks it's output into lines. I seem to remember that the default is at 72 characters.
Why not create logical lines? You could end each logical line with a character of your own choosing (one that is not in the Base64 set). Then read lines lines until your logical end of line is reached.
Roger

Similar Messages

  • Why does Illustrator CC2014 write temporary files instead of updating existing file?

    Illustrator CC 2014 (Win) keeps saving temporary files rather than overwriting an existing file. This results in illustrations not showing as updated in InDesign. The only way round it is to use the Save As command — and that doesn't always work! Also, upon closing a window tab, it frequently changes text in the illustration to default Myriad Pro, without any input from me. I have to undo text changes to make it revert to the intended font.
    I've worked with every version of Illustrator since version 5.0 and this is the first time I've experienced such an apparent glitch. Any ideas why this should be happening top me?
    Nick
    Using: Adobe Creative Suite - Windows 7 Ultimate

    As explained before, when closing a tab, an open *.eps file suddenly acquires the changed asterisk, and when I go that tab it says under Edit "Undo Type Style". Yet, I can't see any change, even when I toggle between "Undo" and "Redo". also, under "Find Font", I can't find any other font other than the branded Interstate font, even though the current font selection window shows Myriad Pro.
    So, on to some serious detective work. I remembered back from the old days that *.eps files can be opened (and manipulated!) using Notepad.
    I saved the file (Figure 8) which said a change had taken place and compared that file with the original by opening in Notepad, copying and pasting into Word and using the latter's compare function. Obviously there are pages and pages to look through, but then I had a Eureka moment! This was what I found:
    dup /FontName get exch definefont pop
    end
    %ADOEndSubsetFont
    /COGQMXCOGQMV+XXXXXXInterstate-Light /XXXXXXInterstate-Light findfont ct_VMDictPut
    /COGQMXCOGQMV+XXXXXXInterstate-Light*1
    [32{/.notdef}rp /space 13{/.notdef}rp /period /.notdef /zero /one /two
    /.notdef /four 3{/.notdef}rp /eight /.notdef /colon /semicolon 9{/.notdef}rp
    /E /F 2{/.notdef}rp /I 9{/.notdef}rp /S /T 12{/.notdef}rp
    /a /b /c /d /e /f /g /h
    /i 2{/.notdef}rp /l /m /n /o /p /.notdef
    /r /s /t /u 138{/.notdef}rp]
    COGQMXCOGQMV+XXXXXXXInterstate-Light nf
    COGQMXCOGQMV+XXXXXXXInterstate-Light*1 [8.8569 0 0 -9 0 0 ]msf
    3.25928 10.4355 mo
    (Figure 8)
    I have used the XXXXXX to protect my client's anonymity, but the crossed out coding "/COGQMX" is to be found in the unchanged file, and the COGQMV in the changed file!
    Although I have described this as a Eureka moment, I actually don't understand the problem, but I feel I have narrowed it down and Mike is right — it IS a font issue!!

  • Read a txt file when I run jar file

    Hi all,
    I have a jar file. In ir there are:
    /file.jar
       |----/pack
       |        |----MyClass.class
       |        |----file.txt
       |
       |----/META-INF
       |        |----MANIFEST.MFI want: when I execute the jar file java -jar file.jar from the java class MyClass to read the file.txt
    When I run this the error is:
    C:\Documents and Settings\pc\Escritorio>java -jar file.jar
    java.io.FileNotFoundException: file:\C:\Documents%20and%20Settings\pc\Escritorio\file.jar!\pack\file.txt (El nombre de archivo, directo
    rio o etiqueta del volumen no es valido)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.<init>(Unknown Source)
            at java.io.FileInputStream.<init>(Unknown Source)
            at java.io.FileReader.<init>(Unknown Source)
            at pack.MyClass.main(MyClass.java:20)
    Exception in thread "main" java.lang.NullPointerException
            at pack.MyClass.main(MyClass.java:31)the code into the java class is:
    package pack;
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStream;
    public class MyClass {
         private static String version = null;
         static String fich = "file.txt";
         public static void main(String[] args) {
              BufferedReader br = null;
              File file = new File(fich);
              try {
                   br = new BufferedReader(new FileReader(MyClass.class.getClass().getResource("/pack/file.txt").getPath()));
                   String j= null;
                   while ((j = br.readLine())!=null){
                        version = j;
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException io){
                   io.printStackTrace();
              } finally{
                   try {
                        br.close();
                   } catch (IOException e) {
                        e.printStackTrace();
              if (version != null)
                   System.out.println("I have read : "+version);
    }in MANIFEST.MF file:
    Manifest-Version: 1.0
    Main-Class: pack.MYClassthanks very much

    thanks you!!
    I have read the file, but I have put the package when I write the file.txt, beacuse If I don't put this, givas me NullPointerException
    Now I have
    InputStream in = Main.class.getResourceAsStream("/pack/file.txt");
    InputStreamReader isr = null;
    BufferedReader reader = null;
    try {
              isr = new InputStreamReader(in, "ISO-8859-1");
              reader = new BufferedReader(isr);
              while ((j = reader.readLine())!=null){
                   version = j;
              reader.close();
    } catch ...Thanks very much

  • Another novice question...I opened a file used "Concatenate String" to write to file creating headers and so forth...a "While Loop" routine is m

    onitoring a voltage and storing it to the same file under the associated header...What I'm having problems doing is after the loop is completed I need to write the MIN\MAX values of the voltage that was monitored in the "While Loop" once it completes. I juBefore the loop the "Concatenate String" peforms the following... line1 col.1 in an excel file is (Tester then Line1 col.2 (the testers name appears) next is a end of line. Then Line2 col.1 is (DATE)header then col.2(TIME)header then col.3(throttle voltage output)header then col.4(MAX VOUT)header then col.5(MIN VOUT) as i said this is perform before the loop with no pr
    oblem. Next during the "While Loop" the actual information for the DATE,TIME,Throttle voltage output,are inserted into Line 3 under the associated header with no problem. What I need to do is wait until the "While Loop" has completed to then store the MAX/MIN, but I can't seem to get the information to end up under the associated header. What do I need to set/use to accomplish this task? Thanks I've attached an excel spread sheet to give an example of where I need the values to be stored.
    Attachments:
    test1.txt ‏1 KB

    onitoring a voltage and storing it to the same file under the associated header...What I'm having problems doing is after the loop is completed I need to write the MIN\MAX values of the voltage that was monitored in the "While Loop" once it completes. I juThis can become hard depending on how much data you will be writing. If you could wait and write the data all at one at the end of the while loop it becomes easier. The problem is that when you write a file it writes it in rows of data not columns. I will attach an example (LabVIEW 6.0) that demonstrates how to do this. It is a hard to describe in text. Basically I create the new columns of data and write empty strings to them on each iteration of the while loop except for the first iteration. The first iteration I write a Max? and Min? into the column information. After the while loop is completed I search the array for Max? and Min? and replace it with the appropriate min and max values.
    Attachments:
    append_column.vi ‏47 KB

  • When I write emails, or messages from Ebay or answer messages, oftem WHILE I am writing the email or message, it simply disappears. Why?

    When I write emails, or messages in Ebay or other sites, while I am typing, the message often just disappears. Why?

    Did you read the Safe mode article?
    Such issues can be caused by an extension that isn't working properly.
    *https://support.mozilla.org/kb/Safe+Mode
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    *Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Good morning! i'd like to know why when I write an email in Mail, it creates numerous copies each second which fill the trash box. My email is set up with IMAP and is a gmail account. Thanks

    good morning! i'd like to know why when I write an email in Mail, it creates numerous copies each second which fill the trash box. My email is set up with IMAP and is a gmail account. Thanks

    Open Mail preferences and select Accounts then MailBox Behavior. You probably need to unclick the safe draft to server.

  • Does any one know what the matrix.dms is? And why it is in my picture folder? When I open this file the unarchiver takes over and I see my entire hard drive when I scroll down I see the matrix.dms file with in the unarchiver.

    Hello everyone. Does anyone know that the matrix.dms file is? And why it may have came to be in my picture folder? When I opened the file the unarchiver took over, then I saw my files in the unarchiver window. I then scrolled down and I saw the same matrix.dms file within the unarchiver window. I made a video of what saw when I tried to open the file, so as to aide in your understanding of reason for my perplexion at this file. Thank you for your help. https://www.youtube.com/watch?v=2QeWH9hRnro&feature=youtu.be

    Hi EMT-B,
    It sounds like you have done all the troubleshooting needed to narrow down your issue with the iPhone camera to hardware. Based on the information you have provided, it appears your iPhone needs to be serviced. The following link should help you get started with the process and has links with additional information on topics such as warranty and service pricing, battery replacement, and express replacement service.
    Apple - Support - Service Answer Center
    http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=ipho ne
    You may need to change the country when you get to the page.
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Access denied when jsp writes to a`network  file system

    Hi
    Can anyone help. Im having big problems with my web application which was working fine when it was hosted on a tomcat windows NT machine. The application was recently upgraded to a Windows 2000 machine. My jsp page which has to write to a network drive can no longer do so. I keep getting ACCESS DENIED.
    My jsp page is as follows:
    <html>
    <head><title>test</title></head>
    <body>This is a test page
    <jsp:useBean
    id="sendSMS"
    scope="page"
    class="podsystembeans.phonetrackbeans.FileWrite"
    />
    <%
    String sms = sendSMS.testIO();
    out.println(sms);
    %>
    </body></html>My javabean is as follows:
    package podsystembeans.phonetrackbeans;
    import java.io.*;
    public class FileWrite
         public String testIO(){
              try{
                       // Create file
                  FileWriter fstream = new FileWriter("R:/outt.txt");
                 BufferedWriter out = new BufferedWriter(fstream);
                  out.write("Hello Java");
                  //Close the output stream
                  out.close();
              }catch (Exception e){//Catch exception if any
                System.out.println("Error testing : " + e.getMessage());
         return "success";
    }OBSERVATION
    If i try and write the file to the local machine for example C and D drives then it works. If i try and write the file to R drive which is another windows 2000 machine then i get access denied. Also if i try and write to a L drive which is a windows NT machine then i get the same message too.
    If i run the above bean as a stand alone application with
    public static void main
    and I run it then it will work and write to any drive on the network.
    Everytime my application fails to write to the network drive my windows machine shows the mapped drives with a red cross on it. I have applied the latest service packs and i have followed microsofts suggestions editing the registry autodisconnect keys. But i am still having problems and it is my java app which is causing it.
    SETTINGS
    Windows 2000 service pack 4
    Tomcat 5 installed on d drive
    java 5 installed on c drive
    mapped network drives to other machines , the network is a 192.168.1.x network
    regards
    antek

    Hi
    Thanks for the pointer, I am trying to follow the suggestion and I want to know is the server.policy same as catalina.policy in tomcat under the conf folder. Also in this policy do i write the ip addresses of the machines i want to access?
    Thanks
    Antek

  • Hi, the problem of deleting files / videos seeds desktop to go into Terminal and then sudo rm-rf ~ /. Trash Pohangina the answers I've had e of someone in her forum but when I write procedures line in Terminal as the Krever my password and it can not writ

    Hi, the problem of deleting files / videos seeds desktop to go into Terminal and then sudo rm-rf ~ /. Trash Pohangina the answers I've had e of someone in her forum but when I write procedures line in Terminal as the Krever my password and it can not write anything there, I write but nothing comes and my problem is not löst.När I want to delete the movie / video image Frin desktop still arrive Finder wants to make changes.Type your password to allow this. But even that I type my password file / video is left I need help in an easier way or another set-even those on the terminal that I can not type my password to solve the problem Regards Toni

    If you want to preserve the data on the boot drive, you must try to back up now, before you do anything else.
    There are several ways to back up a Mac that isn't fully working. You need an external hard drive to hold the backup data.
    1. Boot from the Recovery partition or from a local Time Machine backup volume (option key at startup.) Launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    2. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    3. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.

  • I have a CD burner yet I cannot burn or copy on CD from my collection. When I click on File - burn to CD I get:"To burn to CD you require a CD writer -  Please advise how to burn a collection on a CD Thank you Diane

    Please advise how to burn a collection on a CD - When I click on File then burn to CD - I get:To burn CD you require a CD writer  yet I have one -  which I have used many times with another package.  Also where are the pictures that I have put into a collection stored?  I cannot find them.  I can display them so they have to be stored somewhere in a file or folder etc...I am retired and very new at using this Adobe photoshop edition 3.2  Thank you for your help I am desperate.

    Once the tracks are in your library, you can right-click and use the command Get Album Artwork.  This command will attempt to match your track(s) to the item in the iTunes Store, and get the cover art.
    If that command does not succeed, you will need a copy of the art in .JPG format, either by scanning your CD cover, or by getting it from the web.  Once you have the art, right-click the track, choose Get Info, go the Artwork tab and paste it in.

  • When saving a PDF file, it saves multiple of the exact same documents, why/or how do I change those settings?

    When savind a PDF file, it saves multiple of the same document, why?  Are there settings to adjust or what am I doing wrong?

    This might help - I'm not sure:
    Go to System Preferences (under the Apple logo in the menu bar).  Click "General" and check "Always close windows when quitting an application."

  • What does "extracted channel PDF" mean and why does it continually duplicate on my desktop?  I think it happens when I move a file in Finder to another file and when I copy some web files.  How do I avoid this on my Mac (Mavericks)?  Thanks for your help!

    What does "extracted channel PDF" mean and why does it continually duplicate on my desktop?  I think it happens when I move a file in Finder to another file and when I copy some web files.  I have to immediately move to trash all the duplications on my desktop.  How do I avoid this on my Mac (Mavericks)?  Thanks for your help!

    What application is set to open PDF files? If you CNTRL click on the file and open with Preview does the problem occur?
    If not change the default application to open PDF files to Preview.
    You can do this by highlighting the file and either use CMD i or Get Info , this will open a window with the info on the file with an option to change the application that opens the file.
    That's all I can think of.

  • Why does the folder "C:\Program Files\Adobe\Elements" open automatically when I start my PC?

    Why does the folder "C:\Program Files\Adobe\Elements" open automatically when I start my PC? How do I adjust settings to stop this from happening?

    Hi,
    This folder is probably treated as a program to run at startup.
    So you will have to look at the places where such programs are referenced.
    For instance, you may have a shortcut to that folder in your Start Menu > Startup.
    Or it may be in the Registry.
    Click on Start >  Execute, the type msconfig and click OK.
    This will show you in the Startup tab all the programs launched at startup.
    Astugev

  • When converting a .pptx file of 6MB to .pdf, the file size ballooned to 25MB. The original file was created on a PC. What happened? Why? How to fix? Thx.

    When converting a .pptx file of 6MB to .pdf, the file size ballooned to 25MB. The original file was created on a PC. What happened? Why? How to fix? Thx.

    gssharpe wrote:
    What happened?
    Nothing much. Different formats.
    How to fix?
    Try editing the original file. Resample pics to a lower resolution, check out other graphics, check table borders (eliminate any dotted lines or borders), check font usage. When generating PDF, try Save As (instead of Print > Save As), although I don't expect that'll make much difference.
    Next, open the PDF in Preview, choose File > Save As, choose Format: PDF, Quartz Filterz: Reduce File Size. If that isn't enough, you can use ColorSync Utility to duplicate the Reduce File Size filter, and then edit it for a more aggressive size reduction. But keep in mind that size reduction means lower quality.

  • Why does the document window in illustrator cs6 move to the far left when I reopen the file?

    why does the document window in illustrator cs6 move to the far left when I reopen the file?

    Hi John,
    thanks for the fast response.  cs5 remembered the window position.  I like having the window in the middle as I have a 27" monitor.  I just upgraded to cs6 yesterday and I'm sure it was remembering the window document position.  I think.  If i find out how to fix this, I'll post it here.
    And while I'm on the subject of cs6, why the f*** did adobe combine the stroke and swatches pallettes?  Now I forever have to click stroke and swatch tabs all day.  And I love the army and navy file icons of photoshop and illustrator.  I won't comment on Acrobat X.  ; (

Maybe you are looking for