What should i use? RSA/NONE/PKCS1PADDING not working jre1.5

hi im new to encryption and im using an example off the net, problem is it's not working throwing NoSuchAlgorithmException:
import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.PublicKey;
import java.security.PrivateKey;
import java.security.*;
import javax.crypto.Cipher;
public class AsymmetricCipherTest {
  private static byte[] encrypt(byte[] inpBytes , PublicKey key,
      String xform) throws Exception {
    Cipher cipher = Cipher.getInstance(xform);
    cipher.init(Cipher.ENCRYPT_MODE, key);
    return cipher.doFinal(inpBytes);
  private static byte[] decrypt(byte[] inpBytes, PrivateKey key,
      String xform) throws Exception{
    Cipher cipher = Cipher.getInstance(xform);
    cipher.init(Cipher.DECRYPT_MODE, key);
    return cipher.doFinal(inpBytes);
  public static void main(String[] unused) throws Exception {
Provider p = new com.sun.crypto.provider.SunJCE();
Security.addProvider(p);
    String xform = "RSA/NONE/PKCS1PADDING";
    // Generate a key-pair
    KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
    kpg.initialize(512); // 512 is the keysize.
    KeyPair kp = kpg.generateKeyPair();
    PublicKey pubk = kp.getPublic();
    PrivateKey prvk = kp.getPrivate();
    System.out.println("Public key - " + pubk);
    System.out.println("Private key - " + prvk);
    byte[] dataBytes =
        "i am a secret key abcdefg".getBytes();
    byte[] encBytes = encrypt(dataBytes, pubk, xform);
    byte[] decBytes = decrypt(encBytes, prvk, xform);
    boolean expected = java.util.Arrays.equals(dataBytes, decBytes);
    System.out.println("Test " + (expected ? "SUCCEEDED!" : "FAILED!"));
}

String xform = "RSA";

Similar Messages

  • What should i do my audio is not working?

    my audio is not working
    i had something wrong with my computer so i had to rewrite my hardrive witch whiped everthing clean luckly i saved my songs
    i downloaded the new version of iTunes off of apple.com
    when i downloaded it a little thing pop up said that there were problems with my audio
    now i cant play any songs, its not like there is no sound
    i mean i push play and the song dosent even start
    someone please help me
    Message was edited by: missprincess2101995

    We will need a little more information from you to be able to help.
    - Which computer do you have?
    - Which Mac OS are you using?
    - What audio hardware are you using? If you're using some external audio hardware have you tried selecting Built-in?
    - Have you tried restarting?
    - When you do restart do you hear the boot chime?

  • HT1414 i phone 5 sound dose not work what should i do i restore still not working?

    help cant seem to get the sound on my to work after i install the os7?

    Hi b1kxrw54,
    Welcome to the Support Communities!
    As a first step, I would suggest restarting and/or resetting the iPhone:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    Here are some additional troubleshooting steps for sound on your iPhone:
    iPhone: Can't hear through the receiver or speakers
    http://support.apple.com/kb/TS1630
    Cheers,
    - Judy

  • If i  cannot instal adobe flash driver, what should i use?

    if i cannot install adobe flash driver, what should i use?

    Nothing else will work. Why can't you install it?

  • I noticed that Find My iPhone on iCloud hasn't worked since iOS 8 came out. My device uses iOS 7. My question is: do I need to upgrade my device? If not, what should I do? I do not wish to upgrade my device.

    I noticed that Find My iPhone on iCloud hasn't worked since iOS 8 came out. Whenever I try to use it, it always says "All Devices Offline." This is regardless of whether I am in a good Wi-Fi zone or not.  I like to use Find My iPhone to remotely track my battery charging status whenever my phone is charging in a different room. That's been really handy, which is why I really need to get this fixed. No matter what computer I use, the problem is always the same.
    My device uses iOS 7. My question is: do I need to upgrade my device? If not, what should I do? I do not wish to upgrade my device, especially considering the bad things I've heard about iOS 8.
    Feedback would be welcome ASAP.

    You don't need to update to iOS 8 to use Find My iPhone.  If you haven't already tried, go to Settings>iCloud>Find My iPhone and turn it off, then reset your phone (hold the sleep/wake and home buttons at the same time until you see the Apple logo, then release).  After it restarts, turn Find My iPhone back on and see if it works properly now.

  • Is it possible to raise the bit rate of songs higher than 256 on iTunes? If not what should i use or do to raise the bit rate of songs?

    Is it possible to raise the bit rate of songs higher than 256 on iTunes? If not what should i use or do to raise the bit rate of songs?

    Songs you rip from CD can have their bitrate increased to a maximum of 320Kbps from the iTunes preferences; alternatively, the default encoder can be changed to a lossless one. Songs from other sources have a fixed maximum bitrate.
    (67928)

  • I have been using USB 2.1 10/100M ethernet adaptor. But it takes more than 15 mins to detect network interface. What should I do. I am not using apple's company adaptor. It's local company.

    I have been using USB 2.1 10/100M ethernet adaptor. But it takes more than 15 mins to detect network interface. What should I do. I am not using apple's company adaptor. It's local company.

        jsavage9621,
    It pains me to hear about your experience with the Home Phone Connect.  This device usually works seamlessly and is a great alternative to a landline phone.  It sounds like we've done our fair share of work on your account here.  I'm going to go ahead and send you a Private Message so that we can access your account and review any open tickets for you.  I look forward to speaking with you.
    TrevorC_VZW
    Follow us on Twitter @VZWSupport

  • I keep getting Error 150:30, What should I do? I have not used this program in over a year.

    I keep getting Error 150:30, what should I do? I have not used this program in over a year.

    Well, what program? Anyway, try this:
    Error "Licensing has stopped working"
    Mylenium

  • Virtualization...what should i use?

    Hallo.
    I'm planning  to virtualize a Quad core / 4gb ram. I'd like to build 2-4 virtual machines for testing some advanced features of Asterisk / MySQL and some other well known softwares. I have some licenses for Asterisk addons from digium, so i'd like to maintain them over time, using the virtual machine and moving it.
    What should i use? I don't need fancy 3D Acceleration, just a common abstraction for all the hw i have (pretty standard: usb, nics, harddisks...).
    I was thinking about Xen Server or Virtual Box (anyway, i'm using them for my personal lab, so i'd prefer solutions that don't require a license...).
    The solution should be "headless", i don't want to be forced to login to X every time the guest systems need to be booted...
    Thanks in advances.
    See Ya
    Luca

    i've started playing around with QEMU/KVM a couple days ago, and i like it. was using vbox before, which i didn't.
    i haven't noticed any mouse lag yet, after installing a few of the main distros i wanted to try out again: fedora 19, debian wheezy, ubuntu (latest, whatever the no.). only trouble i have that so far i wasn't able to get a mouse working properly in an archlinux guest    probably something i'm doing wrong, but couldn't figure it out yet.
    tried a few GUI frontends, but found that i'm better off starting VMs from the command line: less confusing, and all of the GUI apps i tried had some quirks, like didn't find proper directories or executables.
    using KVM and virtio drivers, it's pretty fast; admittedly not as fast a bare metal install, but not slower than i remember vbox (just my impression, no benchmarking or such). assuming i'll get the arch guest trouble sorted out, i'll stick with KVM/QEMU.
    Last edited by phanisvara (2013-08-02 11:43:23)

  • What should I use to clean the trackpad?

    I bought iKlear to clean the screen of my MacBook and it works great. I have been using it for years on my iBook. I was reading the directions and it says not to use it on the trackpad. I had used it on my iBook trackpad with no problems. What should I use then to clean my trackpad? Why should I not use it on my trackpad? Anyone have suggestions or used iKlear on their trackpad despite iKlear's warnings?
    Thom

    A very slightly damped cotton cloth works wonders. Just be sure to wring it out as best you can so no liquid gets anywhere you don't want it to be.

  • What should I use? Vectors or...

    I'm storing a large amount of Person objects, this is for a type of game I'm trying to create where it saves the players name, wins, losses, rank, etc in each Person object (this will all be in a text file also). I want these so that they can be sorted by any one of these statistics. I'm not sure how to go about this. Vectors were the first thing that came to my mind, but then I thought about LinkedLists, but I don't know much about them yet, I just know it's an option. My brother told me use LinkedLists, but that's all he would tell me. What should I use for this kind of task? All suggestions are welcome, I need a little help with this design. One more thing about this, players will be added and removed also. I really need some insight, thanks.
    This is a side question, if someone could answer it, that would be nice, otherwise it's ok. How does a LinkedList differ from a Vector? Can't everything a LinkedList do, a Vector can do also with the same amount of ease? All I know that LinkedLists point to the next and previous nodes or something like that, not really sure what its advantage is. Thank you.

    An array memory for holding each of the objects is allocated when you create it, hence you have to define the number of object you want when you create it.
    +--+--+--+--+--+--+
    |I0|I1|I2|I3|I4|I5|  < Indexs
    +--+--+--+--+--+--+
    |V0|V1|V2|V3|V4|V5| < Values
    +--+--+--+--+--+--+Pro: you can access the data quickly, as you have a direct refrence to each value, via it's index.
    Con: Fixed size
    Con: Waisted space
    A Vector is a growable array.
    It does this by creating a fixed sized array, then waiting until it's full, then creating a bigger one and then copying all the data from the smaller, old array to the new, bigger array. This means that every now and again you suffer a performce hit as your array grows.
    Pro: you can access the data quickly, as you have a direct refrence to each value, via it's index.
    Pro: Not a fixed size
    Con: Will slow down when it grows.
    Con: Waisted space
    A Linked List does not have this problem each element holds the refrence to the next, unlike an array where the "system" holds a refrence to each element. This reduces its memory footprint, however its slower to search through as you have to loop through all the objects.
    +----+----+
    |DATA|LINK|
    +----+--|-+
            |     +----+----+
            +-->  |DATA|LINK|
                  +----+----+Pro: Growable
    Pro: Size
    Con: Slow to search
    There are things you can do to speed up a linked list (double linked lists & improve the order in which they are added) but it's still slow.
    I'll leave choosing the data structure to you.

  • What should I use as parameter name in call.addParameter in WS DII client

    I'm using dynamic invocation interface to call a web service in Oracle OC4J.
    The part of WSDL "Types" is:
    <element name="myType" type="tns:myType" />
       <complexType name="myType">
         <sequence>
           <element name="sss" nillable="true" type="string" />
         </sequence>
      </complexType>
    ...My J2SE client has following code I belive create problem:
    call.addParameter("sss", input,MyType.class, ParameterMode.IN);when I invoke the web service, I got error:
    javax.xml.rpc.soap.SOAPFaultException: caught exception while handling request: unexpected element name: expected={http://mypackage/B2BGateway/types}myType, actual=sss
    I changed my code according to this message as it expected to be:
    call.addParameter("{http://mypackage/types}myType",
         input,MyType.class, ParameterMode.IN);I got :
    HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Error parsing envelope: (2, 179) Expected name instead of {.
    seems the "{" should not be part of parameter name.
    Then, what should I use as parameter name.
    BTW, the web service server side code should works fine as I can test it with others client.
    Thanks

    Moved one step further:
    I changed abit to code:
    call.addParameter("myType", input,MyType.class, ParameterMode.IN);I can see the server side got SOAP request:
       <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <env:Body>
             <myType>
                <ans1:sss xmlns:ans1="http://mypackage/types/">abc</ans1:sss>
             </myType>
          </env:Body>
       </env:Envelope>As you can see, the problem in the generated request is "myType" does not have namespace
    Could someone tell me how to fix it.
    Thanks
    Edited by: John618 on Feb 21, 2009 5:03 PM

  • My ipods internet doesnt look how it should , and my app store will not work at all , should i bring it to the apple store to see what they say ?

    my ipods internet doesnt look how it should , and my app store will not work at all , should i bring it to the apple store to see what they say ?

    What do you mean by "my ipods internet doesnt look how it should"?
    What happens when you try to use the App store? Error message?

  • I recently have installed Windows XP for my computer, but it does not start my Ipod information although I already installed Itunes. What should I do, if I do not have the CD to install it from there?

    Hello everyone, I recently installed Windows XP in my computer but now it does not start my Ipod classic information even I just have installed Itunes. What should I do if I do not have my CD to get it from there?

    Try using Firefox. Flash usually works on Firefox when it won't on Safari. I noticed that the Safari does not show the same version as Firefox does. Iwonder if that could be the problem. Safari on the left shows 10.1, Firefox show 10.3

  • X.400 VS FTAM - What should be used?

    Hi Gurus,
    We are planning GTS Customs management and by SAP
    there are 2 ways for comunicating with the customs allowed:
    X.400 and FTAM
    What should be used?
    I know X.400, but FTAM I do not know.
    Is it difficult to set up FTAM and what do we need for FTAM
    and what needs to be done for FTAM?
    Thanks
    Regards
    Dieter

    From my point of view FTAM is the better solution and X.400 is old fashioned.
    FTAM is faster and you don't have to pay for every call like with the X.400.
    You can setup up the communication to customs via SAP PI (e.g. it.x-atlas by itelligence) and you need a FTAM router.

Maybe you are looking for

  • IPhoto 08 Unable to Export

    My hard drive is partitioned into three drives, a primary boot drive, a secondary boot drive, and a swap drive. My iPhoto library sits on my swap drive which has plenty of free space. I recently imported a modest number of photos (~200), made a few i

  • Anyone know where I can get an "Archive and Install" article for Tiger?

    I need to do an archive and install on my Macbook (OS 10.4.11), which runs at the speed of molasses. I've never done it before and am very nervous. Can anyone point me to an article on the website that will tell me how to do it? Thanks!!

  • File without opening the dialog window

    How do I open a file on Mac without dialog window using a pre-defined path network? example: myfile / mytest / mytestfile.ai Thanks

  • Photos out of Focus

    When I was first using iPhoto '11 I realized that while editing my photos they looked out of focus. If I went to the next photo and came back to the same photo I was just editing. The edit was complete and the photo was back in focus. Yesterday I did

  • IMac can't find network printers

    We have 4 Macs in the office and a bank of 4 printers all of which have been working great and connecting together for a while with no issues. However in the last few days the iMac can't find 2 of the printers. We tried to reload them through Print a