Save into a file a SecretKey

Hi,
I'm using JCE module of java and I don't know exactly how I can save a SecretKey into a file:
KeyGenerator kg = KeyGenerator.getInstance("DES");
SecretKey secretKey = kg.generateKey();But then how can I save "secretKey" into a file?
Thanks for all answers.
-- Gandalf

The key itself is serializable
File f = new File("path/to/your/file/yourfile");
          //serialize the initial vector if was just created
          try {
               FileOutputStream fo = new FileOutputStream(f);
               ObjectOutputStream so = new ObjectOutputStream(fo);
               so.writeObject(new String(secretKey));
               so.flush();
                        so.close();
          catch (IOException e) {
               System.out.println("Serialization IOException: " + e.getMessage());
               e.printStackTrace();
          catch (Exception e) {
               System.out.println("Serialization Exception: " + e.getMessage());
               e.printStackTrace();

Similar Messages

  • Save into a file before exiting the program

    Hi All,
    I am developing a java project. It is a console application.
    Initially the program loads content of a file(customer.txt) into an ArrayList.
    Then it gives 3 options:-
    1. Add a Customer
    2. Delete a Customer
    3. Save and Exit
    The changes add or delete are made in the ArrayList.
    The ArrayList is saved back to the customer.txt only when we select the option 3.
    It works fine.
    But instead of exiting the application using option 3, if we close the eclipse window or restart the computer, the changes are not saved to the file.
    So could you please suggest me how we can save the changes in such situations.?

    - Create a class that extends Thread
    - in the run() method place the code that saves your data
    - in your initialization create an instance of your Thread class but do not start it - instead register the object as a shutdown hook (use Runtime.getRuntime().addShutdownHook()).
    When your application terminates the VM will kick off your thread, which should save your data. You may have to experiment a little to get it working right. Remember that only a normal termination signal will allow the VM to continue running so that it can execute your shutdown thread - a kill signal will stop the VM, as will calling Runtime.halt().
    (Edit: note also that this may not work in Eclipse - I've seen problems running shutdown hooks when testing an application under Eclipse.)
    Edited by: PeteFord on Nov 17, 2008 1:39 PM

  • Procedure to save the output of a query into excel file or flat file

    Procedure to save the output of a query into excel file or flat file
    I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
    I have run the query --
    DECLARE @cmd VARCHAR(255)
    SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
    Exec xp_cmdshell @cmd
    error message--
    SQLState = 28000, NativeError = 18456
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
    NULL
    Goel.Aman

    Hello,
    -T:
    Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
    login_id, and password are not required. If
    –T is not specified, you need to specify
    –U and –P to successfully log in.
    -U:
    Specifies the login ID used to connect to SQL Server.
    Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
    -T option (trusted connection) instead of the
    user name and password combination
    I would suggest you take a look at the following article:
    bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
    A similar thread regarding this issue:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
    Regards,
    Elvis Long
    TechNet Community Support

  • A script that captures the coordinates of the mouse clicks and saves them into a file

    Hello,
    I'm trying to create a cartoon taking a movie (I've chosen blade runner) as base. I've got the real movie and I've exported all the pictures using VirtualDUB. Now I have a lot of images to modify. I would like to modify the actors faces with the faces generated by Facegen modeller. I'm thinking how to make the whole process automatic because I have a lot of images to manage. I've chosen to use Automate BPA,because it seems the best for this matter. I'm a newbie,so this is my first attempt using Adobe Photoshop and Automate BPA. I wrote a little script. It takes a face generated with Facegen modeller and tries to put it above the original actors faces. But it doesn't work very good and I'm not really satisfied,because the process is not fully automated. To save some time I need to write a script that captures the coordinates of the mouse when I click over the faces and that saves them into a file,so that Automate BPA can read these coordinates from that file and can put the face generated with Facegen Modeller above the original face. I think that Automate BPA is not good for this matter. I think that two coordinates are enough,X and Y. They can be the coordinates of the nose,because it is always in the middle of every face. It is relevant to knows how big should be the layer of the new face,too. This is the Automate BPA code that I wrote :
    <AMVARIABLE NAME="nome_foto" TYPE="TEXT"></AMVARIABLE>
    <AMVARIABLE NAME="estensione_foto" TYPE="TEXT"></AMVARIABLE>
    <AMSET VARIABLENAME="nome_foto">br</AMSET>
    <AMSET VARIABLENAME="estensione_foto">.jpeg</AMSET>
    <AMVARIABLE NAME="numero_foto" TYPE="NUMBER"></AMVARIABLE>
    <AMVARIABLE NAME="coord_x" TYPE="NUMBER"></AMVARIABLE>
    <AMVARIABLE NAME="coord_y" TYPE="NUMBER"></AMVARIABLE>
    <AMWINDOWMINIMIZE WINDOWTITLE="Aggiungere_layer - AutoMate BPA Agent
    Task Builder" />
    <AMWINDOWMINIMIZE WINDOWTITLE="AutoMate BPA Server Management Console
    - localhost (Administrator)" AM_ONERROR="CONTINUE" />
    <AMENDPROCESS PROCESS="E:\Programmi_\Adobe Photoshop
    CS5\Photoshop.exe" AM_ONERROR="CONTINUE" />
    <AMRUN FILE="%&quot;E:\Programmi_\Adobe Photoshop CS5\Photoshop.exe&quot;%" />
    <AMPAUSE ACTION="waitfor" SCALAR="15" />
    <AMSENDKEY>{CTRL}o</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="1" />
    <AMINPUTBOX RESULTVARIABLE="numero_foto">Inserire numero FOTO di
    partenza -1</AMINPUTBOX>
    <AMINCREMENTVARIABLE RESULTVARIABLE="numero_foto" />
    <AMPAUSE ACTION="waitfor" SCALAR="1" />
    <AMMOUSEMOVEOBJECT WINDOWTITLE="Apri" OBJECTNAME="%nome_foto &amp;
    numero_foto &amp; estensione_foto%" OBJECTCLASS="SysListView32"
    OBJECTTYPE="ListItem" CHECKOBJECTNAME="YES" CHECKOBJECTCLASS="YES"
    CHECKOBJECTTYPE="YES" />
    <AMMOUSECLICK CLICK="double" />
    <AMPAUSE ACTION="waitfor" SCALAR="10" />
    <AMSENDKEY>{CTRL}+</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="20" />
    <AMSENDKEY>l</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="281" RELATIVETO="screen" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="659" MOVEY="281" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="659" MOVEY="546" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="546" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="281" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMSENDKEY>v</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK CLICK="hold_down" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="131" MOVEY="99" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="99" MOVEY="162" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK CLICK="release" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMINPUTBOX RESULTVARIABLE="coord_x">Inserire coordinata X</AMINPUTBOX>
    <AMINPUTBOX RESULTVARIABLE="coord_y">Inserire coordinata Y</AMINPUTBOX>
    <AMMOUSEMOVE MOVEX="200" MOVEY="200" RELATIVETO="screen" />
    <AMMOUSECLICK CLICK="hold_down" />
    <AMMOUSEMOVE MOVEX="%coord_x%" MOVEY="%coord_y%" RELATIVETO="position" />
    <AMMOUSECLICK />
    and this is a short video to explain better what I want to do :
    http://www.flickr.com/photos/26687972@N03/5331705934/
    In the last scene of the video you will see the script asking to input the X and the Y coordinates of the nose. This request is time consuming. For this reason I want to write a script that captures automatically the coordinates of the mouse clicks. The only thing to do should be click over the nose and the script should make the rest. As "c.pfaffenbichler" suggested here : http://forums.adobe.com/thread/775219, I could explore 3 ways :
    1) use the Color Sampler Tool’s input with a conventional Photoshop Script.
    2) use After Effects would provide a better solution.
    3) Photoshop’s Animation Panel might also offer some easier way as it might be possible to load two movies (or one movie and one image) and animate the one with the rendered head in relation to the other.
    Since I'm a totally newbie in graphic and animation,could you help me to explore these ways ? Thanks for your cooperation.

    These are the coordinates of the contours of the face that you see on the picture. Can you explain to me how they are calculated ? The coordinates of the first colums are intuitive,but I'm not able to understand how are calculated the coordinates of the second one.
    Thanks.
    1 COL     2 COL (how are calculated these values ?)
    307.5000 182.0000 m
    312.5000 192.0000 l
    321.5000 194.0000 l
    330.5000 193.0000 l
    335.0000 187.0000 l
    337.0000 180.5000 l
    340.0000 174.0000 l
    338.5000 165.5000 l
    336.0000 159.0000 l
    331.5000 153.0000 l
    324.5000 150.0000 l
    317.0000 154.0000 l
    312.5000 161.0000 l
    309.0000 173.0000 l
    307.5000 182.0000 l
    Message was edited by: LaoMar

  • How can i save the output  of  report into  a file,.

    Hi friends,
                 i was create a executable program .. it was executing fine.. imagine.. my program is just fetching the data from  LFA1  table based on some conditions.. every thing is fine.. and i'm getting the output also..
    but i want to save this output in a separate file.. that means.. what can i do.. my program is executing background... so, i want to save this out put in a file... so, can any one plz provide me the coding steps...
    for example here i'm giving the  my program code.. so, now where can i add the new coding.. and what can  i add ...
    data:begin of  table itab occurs 0,
            lifnr  type  lifnr,
            name1 type  name1,
            end of itab.
    select lifnr  name1  from lfa1  into table  itab .
    loop at itab.
    write:/  itab-lifnr , itab-name1,
    endloop.
    i dont know coding.. I'm learning ABAP... so, can you plz provide the exact coding..for storing these data into separate file from spool..
    help ful answers will be rewarded
    Thanks
    Babu

    Hi  Santhosh,  and  Atish,
         Thanks  for ur responces... i was mention already in my question itself.. that my program is executing  in background.. so,  every day at  6 am it will execute.. but i want to see the result...
    for that what can i do..
    regards
    Babu

  • Saving a PDF file, where it saves into a paint application

    Recently when I save a PDF it saves into a paint application. Does anybody know how to resolve this problem?

    I found the problem..
    "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
    Second box down on this page, there is a  icon and to the right of that there is a box that asks you which application you want to open the program with. And mine was showing a paint icon. I have changed that to Adobe Reader and now it works great!
    Rick
    "Ask and it will be given to you; seek and you will find; knock and the door will be opened to you."
    Matthew 7:7
    Please be environmentally friendly - please don't print this email unless you really need to?

  • How can I save adobe reader file from gmail into my adobe reader app?? i would like to open one file in place where I'm not able to access internet and for that reason i would like to save it. is that even possible?

    How can i save adobe reader file from my gmail into my adobe reader application. or is there any other way i can save it into my phone so I'm able to open in any situation not just from my gmail???

    Long hold on the document in mail and it should give you the open in... option, select adobe reader and the file is now saved locally for viewing even while offline.

  • Save graph shown by cl_gui_html_viewer into pdf file

    hello,
    i am creating graph through cl_igs_chart and display it by using cl_gui_html_viewver.
    now i have a requirment to save graph in pdf file format.
    when righ click on graph and click on save picture as than graph save as bmp file but i want to save graph in pdf file.
    so please tell me how to save a file in pdf format?
    if code for svaing file in pdf format is available than please mention it
    please reply soon...
    thanks in advance

    hello yoganad
    thanks for reply
    i have tried the same codes but fm /1BCDWB/SF00000034' have not any parameter name P_VBELN
    and also it has a compusary parameter  tables IT_AN66 so how i will convert type of internal table of my report into  type matching with table type IT_AN66????

  • How to save the pdf file or word doc into sap table

    Hi Expertu2019s
       I have a pfd file in my presentation server .Now I want to save the pdf file into sap table using module pool program. Whenever i need, I want to open that file from the table and show it in the Screen. Please any one tell me how I can save the file. What is the table name, guide me.
    Regards,
    S.Nehru.

    Hi,
    Try the following code
    FORM gui_upload.
      DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'PDF'.
      lv_file_name = <name of ur file>.
    DATA: tb_file_data TYPE TABLE OF text4096.
    * FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep
        TABLES
          data_tab                = tb_file_data
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "gui_upload
    I dont think you can save the data into sap tables in PDF format.
    With the above code you can save data into an internal table.
    Regards,
    Manish

  • How do I save the Combine Files Into PDF steps?

    I have a set of steps that I would like to repeat in the Combine Files into PDF screen, but I can not figure out how to save that definition file. I am using Adobe Acrobat Pro 10.
    Thanks,

    Hi MarGal,
    Can you please elaborate what you actually want to perform.
    Also let us know what you mean by filing system.

  • How to save CSV into a file

    Hi,
    I’m using the following javascript statement to save the web query result into CSV file.
                window.open(SAP_BW_URL_Get()+
                    "&DATA_PROVIDER=DATAPROVIDER_1&CMD=EXPORT&FORMAT=CSV");
    At present the data is saved into the default file generated  by SAP BW server.
    (example: SAP45B1PWBNRIC5DG8L131GG5GI2.csv)
    Is there any way to save the query result into my own file?.
    i..e I want to give my own file name in a the javascript or in webtemplate to store the query result.
    Please help me on this.
    Regards
    Kandasamy

    If Matt's post doesn't help, consider asking in the Office:Mac forum hosted by Microsoft:
    Office for Mac forums
    Be sure to post your Mac OS version and your version of Offie when you post there. It's a very useful forum.

  • Save Container into data file

    hii
    i have build very big VI that hold arry of container
    in which container it containe variables and arrys.
    i use it to configure the vi action (like controlling high of wave ,amplitude et cetera)
    until now i used "make Current values default" option to save
    variables and arry variables inside the arry container.
    i want to upgrade this technic to somting more advanced. like save this arry into data file.
    when i open the Vi it will read data file
    and when i will wont make change in the Vi i will press save button instead of "make Current values default".
    there is way to do it?
    just save arry of continers into file and read it after it?
    eyal
    Attachments:
    example.vi ‏8 KB

    there may be someting in 8.6 but for previous version I would suggest:
     Flatten to XML.vi
    would preserve the container(cluster) , and then  
    write to xml.vi
    and then when you start the mainvi you put a case t\f  and use
    first call.vi to select only when it start  and in this case true: read xml and  unflatten xml  etc....

  • Save wavefromgraph data of format [f0,df & magnitude)into TDMS file

    How to save Wavefrom Graph data into TDMS file including fo & df along with the magintude.
    I am able to save magnitude alone which is not correct ,coz i have f0 & df also needs to be saved in order to calculate some values
    pls see the below image which shows the i/p format to the wavefrom graph. Also pls do the needful help.  .
    Attachments:
    Waveform.png ‏11 KB

    Hi, check this link
    Simultaneously Write and Read TDMS Data.......
    https://decibel.ni.com/content/docs/DOC-7982

  • Can I save a dng file from Photoshop6 to import back into Lightroom 4

    Can I save a dng file from Photoshop6 to import back into Lightroom 4. I don't understand why this is not straight forward.

    Hello!
    The DNG format's goal is to be an universal file formats for camera raw files: http://www.adobe.com/products/photoshop/extend.displayTab2.html?promoid=DTEHA
    You can save a DNG from camera raw without a problem.
    Just go the the bottom left hand corner of the interface, and select "save image".
    (as explained here in the help files: http://help.adobe.com/en_US/creativesuite/cs/using/WS91C1E0BD-9600-42b2-8EBE-1E012ED61058. html#WSB0DC278F-B3DF-4a60-88BC-B3D6A852C242 )
    Or are you trying to save an file edited in Photoshop as a DNG?
    For what purpose, exactly? A TIFF, PSD or PSB file can have a raw file, saved as a Smart Object (to allow later reprocessing in Camera Raw) and all the pixel/vector editing layers intact.
    If saved with maximize compatibility, it can be opened in Lightroom for cataloging, and editing, if needed.

  • How to save a picture file into Microsoft Access Database?

    I want to save a picture file,such example.jpg file into a Microsoft Access Database in JSP,anybody know how to save picture file into Microsoft Access Database and read this picture file from Microsoft Access Database and then show this picture in a JSP page?
    Thanks in advance.

    Not posible in case of Microsoft Access ..
    You will hv to use oracle for that ....
    search for Blob / Clob

Maybe you are looking for