Writing and retrieving RSA keys from a file

Hello all,
I'm trying to write a generated RSAPublicKey and RSAPrivateKey to a file, and then, later retrieve them.
I thought I could use ObjectInput/OutputStream to do that, but when I do so I get the exception java.io.NotSerializableException: java.io.ObjectOutputStream
(I'm surprised, because RSAPublic/PrivateKey are serializable, aren't they ?).
If this is not the way to do it, I do not know how (no key constructor reading from byte [] ...).
Can somebody please help me ?
Thanks,
Axelle.

Hi,
Can we generate public and private keys from fingerprint?
where can i find a piece of code to view how it is.
Thanks,
Ganesh

Similar Messages

  • How to read DES key from a file?

    I stored the DES key in the file as follows:
    KeyGenerator keygen = KeyGenerator.getInstance("DES");
    SecretKey Key = keygen.generateKey();
    FileOutputStream ostream = new FileOutputStream("t.tmp");
         ObjectOutputStream p = new ObjectOutputStream(ostream);
         p.writeObject(Key) ;
         p.flush();
         ostream.close();
    I don't know if there is problem with the above code, I am just new to java cryptography.
    I have problem read in the key and store it in the DES key object to be used for decryption.
    Can someone please tell me how to do it and a simple example will be appriciated.
    thanks
    Jeff

    Thank you for your help. after getting the key from the file( the output of the key is com.sun.crypto.provider.DESKey@fffe786d, not sure if it is right), I use this key to decrypt the message sent from the client program.
    here is the code:
    ObjectInputStream ois=new ObjectInputStream(data.getInputStream());
    String c = ois.readLine() ;//should I convert the byte[] data to String?
    ois.close() ;
    jTextField1.setText(c) ;//display the cipher text to the first textfield
    byte[] ciphertext = c.getBytes() ;
    // System.out.write(ciphertext) ;
    // get key from file
    FileInputStream in = new FileInputStream("t.tmp");
    ObjectInputStream oin = new ObjectInputStream(in);
    SecretKey Key = (SecretKey)oin.readObject();
    oin.close();
    in.close();
    System.out.println(Key) ;
    //decrypt
    Cipher C = Cipher.getInstance("DES");
    C.init(Cipher.DECRYPT_MODE, Key);
    // Decrypt the ciphertext
    byte[] cleartext1 =C.doFinal(ciphertext);
    System.out.write(cleartext1) ;//doesn't show anything!!
    System.out.println("this is cleartexxt");//doesn't even show this!!
    String display = new String(cleartext1);
    jTextField2.setText(display);
    why there is no output from System.out.write(cleartext1)? where did I go wrong?
    thank you.
    Jeff

  • I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is j

    I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is just a plain photoshop file, a watermark is added, then save as jpeg - the jpeg is saved to a different folder than the original photoshop file.)  It happens for about 10 of 30/40  files approximately . Thank you, Kathryn

    I believe I have figured it out - I need to flatten the image, even though there are no layers except for layer 0, first.

  • Since updating my iTunes I no longer have any controls.  iTune covers the entire desktop and I cannot add from my files.  Can anyone please advise me.

    Since updating my iTunes I no longer have any controls.  iTune covers the entire desktop and I cannot add from my files.  Prior to updating I had a perfectly good iTunes which would allow me to stories for including on a iPod. 
    Can anyone please advise me.

    From my post on what seems like the same issue (found here: https://discussions.apple.com/message/21087892#21087892)
    Take the following steps:
    1) while connected to wifi, toggle off then back on the Show All Music and iTunes Match options shown in my original post. Important: I did this step before, but wasn't connected to wifi, and my music disappeared. Subsequently, I connected to wifi and turned off and then back on those options and everything came back though it was grayed out and my only option was to download music.
    2) To get streaming over cellular back, go into Settings>General>Cellular and scroll down to the "Use Cellular Data for:" options and make sure the iTunes option is set to 'On'
    The above steps will bring back the streaming capability which seemed to go away when you update to 6.1. It didn't ACTUALLY go away, but something about the update toggled off the iTunes option in step 2 above.
    I did a final test by turning off wifi, opening Music app and selecting a song. It played successfully without downloading! Crossing my fingers, but I think I'm good to go!
    Hope this helps!

  • How to read and write a data from extrenal file

    Hi..
    How to read and write a data from extrenal file using Pl/sql?
    Is it possible from Dyanamic Sql or any other way?
    Reagards
    Raju

    utl_file
    Re: How to Create text(dat) file.
    Message was edited by:
    jeneesh

  • SIU - Apply Computer Name and Local Hostname settings from a file

    I am setting up a workflow to image corporate computers and wanting to know how the "Apply Computer Name and Local Hostname settings from a file" works in the Apply System Configuration Settings task.
    We bind the computer to AD and OD and we have a specific naming convention for certain departments and trying to automate the entire imaging process.
    Would this be something that can be done with SIU?

    Well, maybe there's a bug in the latest version (10.5.3) of SIU as this is not what is happening.
    It doesn't seem to matter what I specify for the name parameters I end up with a Bonjour name of ".local".
    I put in a line of the form <Mac Address><TAB>tom<TAB>dick<TAB>harry into the text file used by the Apply System Configuration Settings Action.
    and end up with hostname = tom, Computer Name = dick and Bonjour Name = .local
    I'm building the NetInstall image on a new iMac running 10.5.3 booted out of a second partition and create the image from the main boot partition (also 10.5.3). I then copy the image to my server (10.5.3) and make a second iMac boot up from the NetInstall image.
    For what it is worth the Workflow Actions I am using are:
    Define Image Source
    + NetInstall
    Source: Macintosh HD
    Filter Clients by MAC Address
    + Allow
    <List of MAC Addresses>
    Enable Automated Installation
    + On Volume Named: Macintosh HD
    + Erase before installing
    + Primary Language: English
    Apply System Configuration Settings
    + Apply Computer Name and Local Hostname settings from a file: <FILE>
    Add Packages and Post-Install Scripts
    + Shell Script [Doesn't work - we're discussing in it in another thread]
    Create Image
    In: Public
    Named: NetInstall Classroom
    Volume Name: Classroom iMacs
    Index: 1

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • Private key from a file

    dear all
    I want to create rsa private key from .key file. I searched a lot but could not find a way to do so. how can i do that ???

    'pem' stands for Privacy Enhanced Mail and defines an encoding to ASCII of binary data and not the format of the content of the file. Having said that, it looks to me that your file is a PEM encoded SSLeay format RSA key generated using OpenSSL and encrypted using the '-des3' option. Before loading into Java I normally convert, using OpenSSL, SSLeay files to a PKCS8 format private key and an X509 format public key certificate file. These are then easily loaded into Java.
    The OpenSSL documentation will tell you how to generate the PKCS8 and X509 files but there are numerous sites that will hand-hold you through the commands. Google is your friend. Once you have generated these files then Google will also provide source code for loading them into Java.

  • Retrieve license key from Adobe Acrobat X software install

    Hello,
    Pardon if this is a simple thing to find. My experience with Adobe is pretty much limited to reader and flash.
    I am helping a friend here. He is upgrading his old PC to a new PC. He would like to install his old copy of Adobe Acrobat X on it, but lost the license key some time ago. My question is there a way to find the license key from the software itself?

    If you don't have any luck with obtaining it from your friend's Adobe account, Belarc Advisor should be able to retrieve it from the PC
    Belarc Advisor - Free Personal PC Audit, for software, hardware and security configuration information on your computer.…

  • Recovering keychain and application liscense keys from a crashed disk

    My OS X partition is too corrupted to boot from or repair with disk utility. I have a windows bootcamp partion that I can boot from and the files on the OS X partion can be read from windows and copied to an external hard disk (NTFS if it makes a difference) but it's very slow to copy large amounts of data (as in days for the application folder).  I'd like to recover both my keychain and whatever liscense keys are used to tell applications that I own them.
    My plan is to
    copy everything important. Including what I put above
    Reformat the OS X partition
    Reinstall Snow Leopard
    transfer Keychain information from back up disk
    tranfer liscense information files if they exist
    reinstall Applications
    I'm not sure where the liscense information is stored or if the Keychains file and folder will actually work like this and if I'll have access.
    I can try and copy important applications directly but windows doesn't recognize them as applications so I'm not sure if I'll be missing important information when I try and transfer them back.
    Is this a very bad idea and should I just have a professional try and fix this?
    Thanks
    David

    See setting up a new Mac from an old one or its backups (or use the link in User Tips at the top of this forum)--> http://web.me.com/pondini/AppleTips/Setup.html
    http://support.apple.com/kb/HT3322
    http://support.apple.com/kb/HT3231
    http://docs.info.apple.com/article.html?path=Mac/10.6/en/27921.html
    Hope this solves your problem.
    Message was edited by: leroydouglas

  • VS2012: Retrieve my Project from application files?

    Hi Guys,
    I have lost my project files - I cant locate them anywhere.
    What I do have is the published files with the application files :  .application , . manifest and .deploy.
    Is there any way to retrieve my project from here?
    Any suggestions are most welcome!
    Davie.
    Davie.

    Hi Fenster,
    Test Tools in Visual Studio 2010 and 2012 
    forum is to discuss Visual Studio test issues. Your issue is out of support range of this forum.
    In my opinion, you can't get your whole project from those application files. I don't know about 'retrieve the project'. I suggest consulting your issue on the development
    forum based on your type of your application.
    Thanks,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Retrieving a Project from Local Files ( .dtr folder )

    Hi Experts,
    I was working on a Development Component ( DC) and created an Activity which had all of the project.
    For some reason I never checked it in the DTR. And everything was local to my NWDS
    Now my computer crashed but fortunately I have the backup of all the files on my computer.
    How can I retrieve my project from .DTR folder
    Would appreciate your response on this. Thanks alot!!
    Akshay!

    Hi Akshay,
    Now my computer crashed but fortunately I have the backup of all the files on my computer.--->>hope you have the project files with the latest code change done by you.
    For some reason I never checked it in the DTR. And everything was local to my NWDS & How can I retrieve my project from .DTR folder--->>take the backup of the projects in your local machine. After this try to sync/create the project from the DTR, once done check in the transport view's activity tab for activity created by you.
    IF activity is presented then good you can check the code and confirm the file having your changes or not.
    If you are not able to locate the old activity then create new for the project and with the help of backup project files you can replace the code and do the changes.
    Hope this may help you.
    Deepak!!!

  • How to capture the data within the given range of maximum and minimum values ? from csv files

    My requirement,
    1. Here, the user will provide the range like maximum and minimum values, based on this range, the VI should capture the data within the given range. ( from CSV file as attached )
    2. Then VI should calcluate the average value for captured data and export it to excel.
    This is my requirement can anyone help me on this.
    Many thanks in advance
    rc_cks
    Attachments:
    sample_short.csv ‏2439 KB

    Hi,
    Thanks for remnding me. I forgt to attach the VI, 
    Here I am attaching the VI, what I tried. 
    From attached CSV file, I have to find an average value for columns B,C,D,E,F,G,H,I and AJ, AK. ( data range will be defined  by user ), focused only on these columns
    Here, the scope is to calculate an average value for given data range by user as MAX and MIN data.  
    FYI:  I tried manually for two instance i.e column H & I.  As per H column one steady state values from  7500 to 10500 and similarly in I column 7875 to 10050. So, I gave these as a limit to capture and calculate the average value. But unfortunaltely, requirement has been modified as per below requirements.
    More Info on requirement: 
    --> The user will define the range of data by giving some MAXIMUM and MINIMUM values(for above mentioned columns induvidually), then VI should capture          that data range and it has to caculate the average value for that range of data. This is the task I have to complete. 
    --> I am stuck in creating a logic for data capturing for given range of MAX and MIN value from user, 
         Can anyone help me on this. 
    If my explanation is not clear, Please let me know.  
    Many thanks, help mw
    rc
    Attachments:
    VI_rc.vi ‏25 KB
    sample.zip ‏4166 KB

  • Loading a field of length( 60 and up to 2048) from flat file to BW.

    Hello,
    Can you please suggests ways by which we can load a field in flat file which is of length greater than 60 and up to 2048 digits to BW.
    Facts:
    We cannot have more than 59 length digits in an infoobject
    Observations:
    The idea of using multiple infoobject,ie for 2048 max length it will be 35 infoobjects is not acceptable by my client.
    So, can anyone suggests other ways in BW3.5 for loading a text of length up to 2048 from flat file to BW.

    Hi,
    If you have source field DD/MM/YYYY format, please try this code in the field routine.
    Data : lv_date(8) type C.
    lv_date0(4) = <Source Field Name>6(4).
    lv_date4(2) = <Source Field Name>3(2).
    lv_date6(2) = <Source Field Name>0(2).
    RESULT = LV_DATE.
    Thanks,
    Saru
    Edited by: P. Saravana Kumar on Apr 19, 2009 2:38 PM

  • How a client could retrieve interested data from log file in dbxml?

    I have heard about db_printlog utility in BDB. Is there any similar utility (like shell command or API) in bdbxml?. I want to extract updated nodes from log file.

    I got Berkeley DB 4.8.6 and find db_printlog. It works on bdbxml log file . I used it to translate a log file.
    I used it with following syntax:
    In WinXp Command Prompt:
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    D:\Program Files\Oracle\tmp>db_printlog >mylog.txt
    D:\Program Files\Oracle\tmp>then mylog.txt created. here is some part of it:
    [1][218264]__dbreg_register: rec: 2 txnp 80000017 prevlsn [1][210024]
         opcode: 3
         name: a.dbxml0
         uid: 0xc1 y0 0 0 0 40 0x91 0xed 0xde 0x1d 0 0 0 0 0 0 0 0
         fileid: 37
         ftype: 0x1
         meta_pgno: 22
         id: 0x0
    [1][218348]__txn_child: rec: 12 txnp 80000015 prevlsn [1][184288]
         child: 0x80000017
         c_lsn: [1][218264]
    [1][218388]__db_addrem: rec: 41 txnp 80000015 prevlsn [1][218348]
         opcode: 1
         fileid: 35
         pgno: 21
         indx: 0
         nbytes: 8
         hdr:
         dbt: J3
         pagelsn: [1][193024]
    and so onBut i couldn't find what i was looking for, i mean the Nodes path.

Maybe you are looking for