It seems the basic encryption/decryption functions are unreliable,

I am having trouble with the following code. I am just using the resources provided in the latest SDK.
My code compiles and appears to run without generating any errors. The problem is that I have yet to get back the same string as I entered.
I am following an example in a J2EE security text, but the example seems to be incomplete.
I suspect the problem is not so much with the encryption and decryption functions per se, but rather a problem, not discussed in any of the references I have read, with managing and storing the cipher text. Can anyone confirm or refute my suspicions, and/or show me how to modify my code so that it invariably results in the decrypted string being identical to the original plain text string?
It looks like the cipher text I will get will invariably be binary data, and not just sequences of alphanumeric characters. Can anyone tell me where I can find a function that will generate a unique integer for an arbitrary length byte array, or how one might be constructed? Or, if there is one, perhaps someone can tell me if there is a good encryption algorithm that will create cipher text that consists only of a sequence of alphanumeric characters.
Here are the two relevant functions, along with the relevant declarations of class data members:
    private void encryptBTNMouseClicked(java.awt.event.MouseEvent evt) {
        if ( !OK2run ) return;
        String tmp = PlainTextArea.getText();
        int length = tmp.length();
        if (length < 20) {
            tmp = new String("We need a longer string. we are trying to understand encryption and decryption.");
            PlainTextArea.setText(tmp);
        try {
            myCypher.init(Cipher.ENCRYPT_MODE,sk);
        } catch (java.security.InvalidKeyException ivke) {
            PlainTextArea.setText("Problem with key!");
        byte[] pBytes = tmp.getBytes();
        byte[] cBytes = null;
        try {
            cBytes = myCypher.doFinal(pBytes);
        } catch (javax.crypto.BadPaddingException nspe) {
            CypherTextArea.setText("Problem with padding!");
        } catch (javax.crypto.IllegalBlockSizeException ibse) {
            CypherTextArea.setText("Problem with block size!");
        tmp = new String(cBytes);
        CypherTextArea.setText(tmp);
        tmp = PlainTextArea.getText() + "\n\nWrapped Key = " + wrappedKey;
        PlainTextArea.setText(tmp);
        decryptBTN.enable();
    private void decryptBTNMouseClicked(java.awt.event.MouseEvent evt) {
        String tmp = CypherTextArea.getText();
        byte[] cBytes = tmp.getBytes();
        try {
            myCypher.init(Cipher.DECRYPT_MODE,sk);
        } catch (java.security.InvalidKeyException ivke) {
            DecypheredTextArea.setText("Problem with key!");
        byte[] dBytes = null;
        try {
            dBytes = myCypher.doFinal(cBytes);
        } catch (javax.crypto.BadPaddingException nspe) {
            CypherTextArea.setText("Problem with padding!");
        } catch (javax.crypto.IllegalBlockSizeException ibse) {
            DecypheredTextArea.setText("Problem with block size!");
        tmp = new String(dBytes);
        DecypheredTextArea.setText(tmp);
    private javax.crypto.KeyGenerator kg;
    private boolean OK2run = false;
    private javax.crypto.SecretKey sk = null;
    private javax.crypto.Cipher myCypher = null;
    private byte[] theBytes = null;
    private String wrappedKey = null;Thanks,
Ted

One should not try to create a String object from the encrypted bytes using
tmp = new String(cBytes);
because it is not guaranteed to be reversible.
If you need a String then use Base64 or Hex encoding. Google for Jakarta Commons Codec.

Similar Messages

  • How do I digitally sign with reader XI when the fill and sign functions are grayed out?

    I am using Adobe Reader XI. I am suppose to digitally sign a fillable .pdf document for online submission. However, the fill and sign functions are grayed out.
    What are my options to put a signature in the signature box of the document?
    Thank you in advance!

    Pat Willener,
    Thank you for replying.
    Here is an image capture of the properties.
    The document is part of a job application that is suppose to be digitally signed and submitted soon. I have thought about printing, signing, and redigitizing to submit, however, the cells are statically sized and do not expand to include all of the information when printed.
    Any suggestions will be appreciated.

  • Please remove the trial Visual voice mail and restore the basic voice mail functionality.

    Please remove the trial Visual voice mail and restore the basic voice mail functionality.

    To Disable Visual Voice Mail
    Sign in to your My Verizon online account. On left side of page find the drop down menu.
    Click to open menu, then go to change features and locate Basic Visual Voice mail.
    Locate the button Basic Visual Voice Mail and click the Red Remove Box.
    Scroll down until you see the listing: Basic Voice Mail, Visual Voice Mail etc. and click the Red Add box by Basic Voice Mail to add on this service.
    When you're done making changes click next at the bottom of the screen and then ok.
    Go into your device and set up your required Basic voice mail program. You may continue to receive an  error  message “new voice mail update" for a period of time”.   Hope this helps, GalaxyClass

  • Is it possible to add an HP all in one printer to my vetwork via UBS on an Airport Extreme so that the scanner and print functions are available over the network?

    Im very new to this "networking thing" so your patience is welcome. I have managed to get the Time capsual AE up and running and thanks to bonjour I have a printer via USB working. However, its an all in one machine and I can not work out how to get the scanner to work over the network - or even if its possible. Is this possible?

    No, you cannot scan over the network, unless the printer has network capability.. in which case the printer must connect via ethernet or wireless not USB.
    All USB printers are designed as local printers not network.

  • I have os 10.8.5.  my mail program is horribly slow, though the rest of my functions are all good.  ?solutions

    I have OS X 10.8.5.  All is well, but my mail program is very slow.  It takes way too long to open/close/delete an email.  ??any thoughts on how to fix?

    Quit Mail if it's running. This procedure will have no effect unless you quit Mail when you begin.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    sqlite3 L*/C*/*.mail/*/L*/*/*/C*.db vacuum; sqlite3 L*/M*/*/*/E*ex vacuum
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V).
    You should see a new line ending in a dollar sign ($) appear below what you entered. If not, press return. You can then quit Terminal and relaunch Mail. Test.

  • Relation between business process and functional area during the role search

    Hi Experts,
    We have 2 functional areas in which we have different business process involved.
    During the Access request, if the user selects  one functional area then business process related to that functional area should come.
    Is there any functionality in GRC, where the mapping between functional are and business process to be done?
    Thanks,
    Sriram

    Hi Sri,
    there is relationship between 'Business process' and 'Sub-business' process as in configuration parameter you can setup that once business process is selected only relevant sub-process will be selected.
    There is no such a relation between functional area and business process.
    Filip

  • Change in the functional area impact

    The budget data was stored at a Cost Center level. The cost center was assigned to a Functional Area ahich was changed on a later date. The data for the cost centers that were migrated from the old to new functional area was locked. Any changes that i make to the cost centers impact the new Functional area.how do i proceed ? is it possible to erase the data stored in the previous functional area?

    Thank you for your reply.
    A bit more detailed explanation of the prob:
    The General Marketing Budget data was stored in ECC at Cost Center level, on the 17th of January (using SAP transaction: KP06) At that time, all the General marketing Cost Centers (Gen Mkt CCu2019s) were assigned to the Functional Area H240.
    By the 27th of Januaryu20192012, the functional area of some GenMkt CCu2019s was changed to the new GenMkt u2013 Product Manager functional area (Q240).
    This mean that for the CCu2019s that migrated from H240 to Q240, budget data is u201Clockedu201D in H240 functional area. Weu2019ve tried to delete Budget planning for these cost centers (using transaction KP06) but data remains in H240. Any changes that we make for these CCu2019s (delete/overwrite), impact the new functional area (Q240).
    How should we proceed? Is it possible to erase the General Marketing data stored in the 17th of January?

  • Encrypt/Decrypt data, multiple public keys using Bouncy castle api?

    Hi all.
    I need to implement encrypt/decrypt functionality of some data with many public keys using bouncy castle api and EnvelopedData class in java 1.4 SE.
    Could someone give me examples how to do it. I searched whole the internet and i could not find simple example.

    Hi thanks very much.
    I had a quick look at the examples. I will see if they could help me.
    Here is more specific what i want:
    Encrypt data with multiple public keys that are kept in .pkcs12 file.
    And decrypt the data using coresponding private key after that.
    I must use bouncy castle api for java 1.4 se.
    Best regards
    Edited by: menchev on Nov 13, 2008 8:26 AM

  • Custom Search Help for Functional Area of Cost Centre(KS01/KS02)

    Hi,
    I need to implement a custom search help and custom enhancement for the field Functional Area in Basic Data tab of Cost Centre Create/Change(KS01/KS02) transactions. Details of the requirement are as below:
    1. There will be a custom relation for the Cost Centre category and Functional Area which was maintained thru a SAP standard table TKA05 and a custom table.
    2.When the relation to Cost Centre category and Functional Area is a one to one it exist in the TKA05 and if its one to many it will be maintained in the custom table.
    3. The requirement is when the Cost Center to Functional area is maintained in table TKA05(One to One) in this case the corresponding Functional Area needs to be populated automatically after entering the cost centre and pressing a enter key by user.
    4.When the Cost Centre Category and Functional area does not exist in table TKA05 and existing in custom table(One to Many) in this case the F4 should be enabled for user selection with the list of Functional area values corresponding to the cost centre category entered that are maintained in the custom table.
    As per the functionality provided by SAP the input help(F4) of the field Functional area in Cost Center does not have any relation with Cost Centre Category. The existing F4 is from the Value Table(TFKB) attached to the domain of FKBER.
    Please provide your valuable inputs to implement the above requirement. Your input will be rewareded.
    Thanks in advance,
    Regards,
    Prasad.

    kalyani,
    i can see your requirement in below way..
    as it just reads: you need to assign the standard cost center help to a z cost center field in component /SAPSRM/WDC_UI_DO_ACC.. which actually is fetched though the component /SAPSRM/WDC_UI_BACKEND_SH
    so, if you see the component controller of SAPSRM/WDC_UI_DO_ACC you will see the component
    USAGE_SH_F4     /SAPSRM/WDC_UI_BACKEND_SH                        
    USAGE_SH_F4     /SAPSRM/WDC_UI_BACKEND_SH     INTERFACECONTROLLER
    so you can replicate the same functionality for your z field.
    but can you clarify one thing.. why are you going for this z field in place of standard field ?

  • Help ! Need PCI Encryption/Decryption Controller Driver for New HP 355 G2 (AMD) w/Win 7 Pro 64 Bit

    Just rebuilt new HP 355 G2 to Win 7 64 bit.  The ONLY driver I can not locate or get to work is the PCI Encryption/Decryption Controller. I installed all latest drivers for this model/OS from both HP and AMD sites still no luck. AMD autodetect utility and Catalyst software installed all other drivers successfully except this one and when completes says all drivers, including chipset, are installed successfully and current.
    I am at a complete loss where to get this driver from a OEM site, can you help ?
    Device ID's:
    PCI\VEN_1022&DEV_1537&SUBSYS_15371022&REV_00
    PCI\VEN_1022&DEV_1537&SUBSYS_15371022
    PCI\VEN_1022&DEV_1537&CC_108000
    PCI\VEN_1022&DEV_1537&CC_1080
    Thanks !!!
    This question was solved.
    View Solution.

    Hi:
    You need to run this driver and then manually install it.
    http://h20565.www2.hp.com/hpsc/swd/public/detail?swItemId=vc_133833_1
    To manually install the driver go to the device manager and click on the PCI Encryption/Decryption Controller needing the driver.
    Click on the driver tab.  Click on Update Driver.
    Select the Browse my computer for driver software option, and browse to the driver folder that was created when you ran the file.
    That folder will be located in C:\SWSetup\sp66974.
    Make sure the Include Subfolders box is checked, and the driver should install.
    Then reboot.

  • Better Encryption/Decryption Method - SMIME or PGP ?

    1. Which is the default encryption/decryption method provided in BizTalk Server ?
    2. What is PGP Encryption/Decryption ?
    3. What is SMIME Encryption/Decryption ?
    4. Which is better out of the two ?

    There is no default encryption/decryption method provided in BizTalk Server. BizTalk uses encryption/decryption using certificates (when you use certificates ). More about them here.
    BizTalk Server : Encrypting and Decrypting a Message.
    Pretty Good Privacy (PGP) is a data encryption and decryption computer program that provides cryptographic privacy and authentication for data communication.
    Soruce: Wiki. In Specific to BizTalk, messages are encrypted/decrypted at the entry point into BizTalk, right place is in pipeline using custom pipeline component. There is one available
    which you can learn more here.
    https://code.msdn.microsoft.com/windowsdesktop/BizTalk-Sample-PGP-ebcbc8b2. Also there is a thrid party adapter and pipeline component available to implement extensive suite of PGP features in BizTalk-
    https://www.eldos.com/bizcrypto/biztalk-pgp-adapter-pipeline.php
    S/MIME (Secure/Multipurpose Internet Mail Extensions) is a standard for
    public keyencryption and
    signing of MIME data. S/MIME is on an
    IETFstandards track and defined in a number of documents, most importantly RFCs 3369, 3370, 3850 and 3851. S/MIME was originally developed by
    RSA Data Security Inc.
    soruce Wiki. In BizTalk, when you use certificates with two-key security, it supports public key encryption of outbound messages and decryption of inbound messages based on Secure Multipurpose
    Internet Mail Extensions (S/MIME). BizTalk Server uses S/MIME version 3 for encryption of outbound messages, and S/MIME versions 2 and 3 for decryption of inbound messages. Reference:
    http://msdn.microsoft.com/en-us/library/aa559843.aspx
    When you discuss about which is more native, I would choose S/MIME which can be implemented with certificates and out-of-MIME pipeline components. 
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Functional Area populating in MIRO during simulation

    Hello,
    We are in ECC6.0 EHP4, we have a need to Populate "*Functional area*" into table BSEG, for which we have maintained this in PO, and through PO this comes on to MIRO screen, but when I do simulation, The simulation screen does not show "functional area" which in turn does not populate in BSEG, how can we have this value for the field "Functional area" be populated into BSEG, if I have to use an user exit, I need one that is a part if 'MIRO" and  updates the BSEG table

    Hi Satya,
    functional area basically define in FI module as Financial Accounting Global Settings/Financial Accounting Definition/Financial Accounting Global Settings (New)
    which is just Typical functional areas are Sales, Production, Marketing, Administration and Research & Development.
    so its segregating business by it department as we created via below path:
    Financial Accounting Global Settings (New)->Ledgers->Fields->Standard Fields->Functional Area for Cost of Sales Accounting->Define Functional Area
    Regards,
    Sanjeev

  • PCA Functional Area Report Problem With Co-Product Settlements

    I have built a profit center functional area report for use in a manufacturing client.  The reason is because the factory cost centers flow to the product cost (via costing sheets) and the administrative cost centers are expensed monthly.  However, SAP seems to have no other approach to handle the issue where common expense elements must be reported in these two separate sections.  Anyway, here is my problem:
    After creating the functional areas and matching them to each cost center appropriately and then applying a different functional area to orders, I see that settlement of co-products causes my report to zero out the functional area that should match the overhead cost centers.  These obviously should not be impacted by settlement and I see that they are not impacted in the transactional data.  However, the functional area report shows a different story.  I believe it somehow has to do with the unusual way that co-product split up and settle versus other types of orders.  I may need some sort of subtitution rule, but like I said, the raw transactional data looks correct and the report should bring in these values. 
    I used ledger 8A if that helps.  I am sure I missed some small thing somewhere.
    David

    It looks to me like the New G/L may have taken care of some of my issue.  The FI reconciliation G/L account (690000 usually) includes the secondary cost center postings as well as the secondary order postings.  The cost center side of the secondary transaction reflects the functional area for cost centers (Factory Exp or Admin Exp in my case), whereas the order side of the secondary posting shows the functional area associated with order consumption (Net Consumption in our case). 
    This appears to mean that the standard report for Functional Areas from FI should work to break up the income statement for manufacturing purposes.  This report is S_PLO_86000029.  That report looks to me like it will replace my need for a PCA based Functional Area Report.
    David

  • Seeking general knowledge of functional areas(FI, CO HR, SD, MM, CRM)

    Hello Experts,
    I do come across this phrase in my job searches:
    "knowledge in at least 1-2 functional areas. (FI, CO HR, SD, MM, CRM)"
    Can you help or direct me to get a general overview of these functional areas?
    Thanks.

    http://help.sap.com/saphelp_nw04/helpdata/en/37/5fb13cd0500255e10000000a114084/frameset.htm
    they basically expect you to know the tables for these functional areas and the extractors & reports which are available with standard business content...
    assign points if it helps

  • Functional area error.

    hi friends...I need a help with this question...very urgent...
    I am getting an error message of " P&L not complete and functional areas missing"
    I dont exactly know what needs to be done for that.
    How do i define a missing fuctional area ?

    Hi,
    In IMG under the "Enterprise structure" you will define the Functional areas.
    Also you can define:IMG-.>Fin.Accting basic settings->Define Func.Area.In the next step,you enter Functional area:IMG-.>Fin.Accting basic settings->enter Functional area.->enter Functiona area in GL master.
    Once entered,the system will ask for Functional area for the relevant GL a/c.
    If usefull assign points.
    Regards,
    AMIT

Maybe you are looking for