I need help!!how can i resolve the error message?

     Security.addProvider(new com.sun.crypto.provider.SunJCE());
KeyGenerator kg = KeyGenerator.getInstance("DES");
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES");
byte[] data = "Hello World!".getBytes();
out.println("Original data : " + new String(data));
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] result = cipher.doFinal(data);
out.println("Encrypted data: " + new String(result));
               String temp=new String(result); //error occure here!
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] original = cipher.doFinal(temp.getBytes()); //if replace temp.getBytes() to result,that's ok��
out.println("Decrypted data: " + new String(original));
error message��
javax.crypto.BadPaddingException: Given final block not properly padded
     at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA6275)
     at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA6275)
     at javax.crypto.Cipher.doFinal(DashoA6275)
and how can i post the key and Encrypted data to columns whose type is varchar in a table in my database,and next time to get the values from my database and translate to key to Decrypte the Encrypted data ?
thanks!!

I presume the no-padding error is happening when you attempt to do the decryption. This means, that in some way, you've modified the encrypted data, and the size of the data is not what the cipher object expects. You don't show all your code here, but most likely, you tried to put result into a string (temp?) and when you do your temp.getBytes(), the array of bytes you're getting back is not the same as the array called result in your post.
Steve

Similar Messages

  • How can we view the error message numbers in the web ui?

    Dear all,
    How can we view the error message numbers in the web ui? It gives the error but no number.  It is possible to debug in web UI so how can we accomplish this?
    Thanks,
    FK

    Hi  Fakhan,
    You can absolutely do that.
    Check the class: CL_BSP_MESSAGES
    Also if you want to find out the exact Message Class and Message Number, go to table T100, type text in field TEXT, you will get Message Class and Message number in fields ARBGB and MSGNR respectively.
    I hope this helps.
    THanks
    Vishal

  • How can i see the error message?

    hi, i have written a procedure in the database 10g, with my own error, and it works. but, when my exception occurs, i want to see my ora-20000-message in the footer of the isql-screen in the same way like normal ora-errors do it. because, now the code handles the exeption, but i can not se any message.
    thx.
    (zahl1 in number, zahl2 in number)
    as
    maxvertrag number;
    ergebnis number;
    myerror exception;
    pragma exception_init(myerror, -20000);
    begin
    select max(vertragsnr) into maxvertrag from robertl.tblugovor;
    ergebnis := zahl1+zahl2+maxvertrag;
    if ergebnis>104
    then
    RAISE_APPLICATION_ERROR (-20000, 'Result is > 104!');
    end if;
    exception when myerror then
    ergebnis:=0;
    end;

    This is answered in how can i se the error message?.
    As a side note, you generally don't need to cross-post in these two fora, as many of us frequent both.
    Cheers, APC

  • HT1369 how can i resolve the error 13019 ?

    My ipod has become completely useless, unable to sync any new music from itunes.  No matter which of my PCs I use, I constantly get the error message 13019. Help

    I have. I did not have any voice memos to deselect and I only had selected playlists checked.  I don't have anything but music on my ipod.  I am afraid to reformat or "re sync" the ipod due to the warnings stating it will remove everything and re sync because I have music from multiple computers and multiple itunes on my ipod and I am afraid I will be unable to recover all of my music if I do this.  Is there a safe way to completely backup what is currently on my ipod before moving forward with a complete reformat ? Thank you in advance for any advice whatsoever, this has been a problem for months.

  • How can we restart the  Error Messages

    Hi,
             I have a Secnario like  JDBC- To - RFC(R/3)   .. here my Receiver(R/3 system was down in particular time..  so, the messages was  not processed successfully..
    but after the R/3  server was up .. the  remaing messages are processed normally.. except the   those messages are failured in that particular time server was down..
    if  I saw in SXMB_MONI.. the message was showing  (system error--  System Error - Restart is not possible... )   so, how can we  solve this issue..
    How can we restrt the  messages  from SXMB_MONI..
    Regards
    jain

    Hi Jain,
    You cant restart the synchronous messages nor u can restart it............Hence the messages regarding synchronous issues cant be solvable.....The only way you have is to Resend the same data by again posting it in the Outbound Folder (Outbound side or sender side).........So once the sychrouns message failed means then it is unslovable ......So just follow the above mentioned way of resending the data by posting in the Out folder......................
    Reward with points if helpful
    Regards
    Sai

  • Web services. How can I get the error message?

    Hello.
    I am trying to run a report using XmlViewService. If any report has an error then executeXMLQuery returns empty result set (<rowset xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"></rowset>), not the error message. How can i know if a report fails with error or it exactly return empty result set.

    HI,
    Open the C:\OracleBI\web\msgdb\messages\resultviewtemplates.xml file modify the
    kuiNoResultsViewEditor webmessage as per your requirement...
    mark if helpful/correct...
    thanks,
    prassu

  • How can I customize the error message UIX STRUTS ADF

    Hi dear forum:
    I need to customize the error message?
    Error
    Id - JBO-27014: Attribute Id in AppModule.BackupsView1 is required
    Fecha - JBO-27014: Attribute Fecha in AppModule.BackupsView1 is required
    AplId - JBO-27014: Attribute AplId in AppModule.BackupsView1 is required

    Repost:
    I need to customize the error message when I insert a new row with wrong values in ADF STRUTS UIX, where can I changue the default values for the message?

  • How can i get the error message from the thrown/raised exception?

    DB version:10gR2
    Examples for this thread taken from
    Want Stored Procs to get exectuted regardless of preceeding SPs Success or
    I have a package with several functions and procedures inside.I created a caller procedure called callProcs, which will execute various procedures within the package in the appropriate order.
    In the below example i cannot get the error message thrown from line 20
    create or replace package body mypackage
    is
    variable_proc1 number;
    variable_proc2 number;
    variable_proc3 number;
    v_result       number;
    my_exception   exception;
    procedure proc1
    is
    begin
    select 8/0 into variable_proc1 from dual;
    exception
              when others
              then raise my_exception; ----line 20
    end;
    procedure proc2
    is
    begin
    select 1 into variable_proc2 from dual;
    exception
              when others
              then
                   null;
    end;
    procedure proc3
    is
    begin
    select 3 into variable_proc3 from dual;
    exception
              when others
              then
                   null;
    end;
    Procedure caller_proc
    is
    begin
    proc1;
    proc2;
    proc3;
    v_result:=variable_proc2+variable_proc3;
    dbms_output.put_line('The output is '||v_result);
    exception
              when my_exception
              then
    dbms_output.put_line('Heyyyyy the error is '||SQLERRM); -- exception caught at line 64 of caller proc
    end;
    end mypackage;
    When i try executing the caller proc, i don't get the error. Instead i get the text User-Defined Exception as shown below
    set serveroutput on
    exec mypackage.caller_proc;
    Heyyyyy the error is User-Defined Exception
    PL/SQL procedure successfully completed.Edited by: user10633418 on Mar 10, 2009 11:30 PM

    Thank you justin.
    Sorry my earlier post was a bit ambiguous.
    I wanted the error generated at proc1 to be captured at caller proc's Exception handling section (line 64) so that i could log the error to an ERR_LOG table.
    I can actually log this error at proc1 itself like
    exception
    when others
    THEN
    error_message :='My custom message for the particular proc '||SQLERRM;
    dbms_output.put_line(error_message);
    logerror(error_message); --an autonomous error logging proc
    raise;But there is a RAISE statement in proc1's exception handling, so the exception gets propogated to caller proc's exception handling section {color:#ff0000}*and another redundant row will be created at ERR_LOG table for the same error because there is a*{color}
    logerror(error_message);--an autonomous error logging proc
    in the WHEN OTHERS section of exception handling section of the caller proc
    I want to avoid the creation of this redundant row in ERR_LOG table.

  • How can I Fetch the error message from a OAF page

    Hi,
    A confirmation message is coming on the page,I want to catch the error message and depending on its value want to add some validation.
    Is that possible to fetch the error message from the page?

    is it a confirmation message or an error message ?
    Code in the OAF page would be raising an OAException with a message name defined in message dictionary.
    you would need to look at the code to understand where this is thrown from and add your validation there.
    Tapash

  • How can i save the error message?

    In the execution of the integration process, and i get
    the mapping error as follow:
    RuntimeException in Message-Mapping transformation: Exception:[java.lang.IllegalArgumentException: Cannot cast to float. ] in class com.sap.aii.mappingtool.flib3.Stat method sum[com.sap.aii.mappingtool.flib3.Plainer@dddd08]
    <b>Now what i want is to save this message.</b>
    <b>How can i save this message?</b>
    Thank you for your advise and reading

    Hi,
       An exception name is just any string, like, "timeout"
    You usually have a control step, which waits for somethime (say a minute) and then transfers the control to exception handler, who handles the exception.
    <i>but i dont know from where i get the exception?</i>
    It not required for us to know from where the exception is raised as long as you have created an exception handler.
    The integration process, will search for the required exception handler and execute it. Make sure, that the exception handler is in one of the branches of the block.
    Hope this helps.
    Regards,
    Smitha.

  • How can i se the error message?

    hi, i have written a procedure in the database 10g, with my own error, and it works. but, when my exception occurs, i want to see my ora-20000-message in the footer of the isql-screen in the same way like normal ora-errors do it. because, now the code handles the exeption, but i can not se any message.
    thx.
    (zahl1 in number, zahl2 in number)
    as
    maxvertrag number;
    ergebnis number;
    myerror exception;
    pragma exception_init(myerror, -20000);
    begin
    select max(vertragsnr) into maxvertrag from robertl.tblugovor;
    ergebnis := zahl1+zahl2+maxvertrag;
    if ergebnis>104
    then
    RAISE_APPLICATION_ERROR (-20000, 'Result is > 104!');
    end if;
    exception when myerror then
    ergebnis:=0;
    end;

    Hello
    The problem is that you are catching the exception with:
    exception when myerror then
             ergebnis:=0; But then that's it, you aren't doing anything more with the error. As far as oracle is concerned, you've explicitly handled the exception, so it doesn't need to worry anymore. If you want the error propagated up to the calling applicaiton, you need to either re-throw the exception by doing :
    exception when myerror then
             ergebnis:=0;
             RAISE; --this will re-throw the exceptionOr, you need to ignore the exception at this level and let the next level up handle it. It all depends on your exception handling strategy really:
    DECLARE
         my_Exception     EXCEPTION;
         PRAGMA EXCEPTION_INIT(my_exception, -20001);
    BEGIN
         BEGIN
              RAISE_APPLICATION_ERROR(-20001,'The sky is falling down');
         EXCEPTION
              WHEN my_exception THEN
                   NULL;
                   dbms_output.put_line('My exception was trapped and nothing else was done');
         END;
         dbms_output.put_line('Just before the 2nd call to raise application error');
         RAISE_APPLICATION_ERROR(-20001,'The sky is still falling down, do something');
         dbms_output.put_line('This line wont be output because the exception has been raised');
    EXCEPTION
         WHEN my_exception THEN
              dbms_output.put_line('This line will be output just before the exception is displayed');          
              RAISE;
    END;

  • [Need Help] How can I install the trial of Adobe After Effects? Since I cannot find it in my creative cloud.

    Hi, I want to try the trial of After effects but I haven't found any after effects in my creative cloud. Any solutions?
    Thank you

    If an application is not listed it is normally because your machine does not meet the system requirements for that application.  Check the AFter Effects requirements against your machine to see if there is a mismatch...
    After Effects - http://helpx.adobe.com/after-effects/system-requirements.html

  • How can I fix the error message"we noticed you may have signed in or signed out in another window click OK to reload your page

    this message happens everytime I close out of firefox and try to reopen it

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove the Cookies" from sites causing problems:
    * Tools > Options > Privacy > Cookies: "Show Cookies"

  • How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    Try asking at ifixit.com. The iPhone is not considered user servicable. You're not going to get much help on an Apple sponsored forum.

  • Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    The Mac OS X and iOS versions are separate products

Maybe you are looking for