Problem using java crypto class... Please help me

Hi, i'm trying to do application that send information via socket, and i have to send the data encrypted,
i`m trying to implemented the RC4 algorithm.... I read an article that said that the java sdk 1.4 has already
implemented the securities classes. So I made this little program:
import javax.crypto.spec.*;
import javax.crypto.*;
import java.security.*;
import java.io.*;
public class MicroRC4
public void encriptaClavePublica(String trama)
Cipher rc4Cipher;
byte[] rc4KeyByte;
SecretKey rc4Key;
String keyStr;
String messageEncryp;
byte[] messageEncrypByte;
rc4Key = null;
messageEncryp = trama;
// Clave para encriptar el mensaje
keyStr = new String();
keyStr = "12345678";
rc4KeyByte = new byte[8];
messageEncrypByte = new byte[255];
for(int i=0; i < 8; i++)
rc4KeyByte[i] = (byte)keyStr.charAt(i);
try
for(int i=0; i < messageEncryp.length(); i++)
messageEncrypByte[i] = (byte)messageEncryp.charAt(i);
rc4Key = (SecretKey)new SecretKeySpec(rc4KeyByte, "RC4");
rc4Cipher = Cipher.getInstance("RC4");
rc4Cipher.init(Cipher.ENCRYPT_MODE, rc4Key);
byte[] result = null;
result = rc4Cipher.doFinal(messageEncrypByte);
System.out.println("Usage:"+result);
catch(Exception e)
System.out.println(" Error: " + e.getMessage());
System.out.println("\n........................................\n");
I don't know what is wrong but when i run the application it show me the following message :
Error: Algorithm RC4 not available
Does anybody know what is wrong ??
Does anybody can help me ??
or tell me when can i find some source code that implement de RC4 algorithm
Thank's in advance..
Alejandro.

Hi Alejandro,
In the ends i decided to implement the algorithm by
myself, i did it... any way thank's again.... If
anybody want to see the code, send me a mail......
AlejandroCan I also get the source code? my email id is [email protected]
Thanks a lot!
Srik.

Similar Messages

  • Error Using java command. Please help!

    Ok, I'm having problems running my java programs. I use the javac command, and it compiles it right, and makes the class file. But if I type
    java anything
    It won't work. It comes up with the error message:
    Exception in thread "main" java.lang.NoClassDefFoundError: BigDebt
    With BigDebt as the class file. That error message comes up if I type:
    java anything
    java blah.class
    I have version 1.3.
    It would be GREATLY appreciated if someone could help.

    It appears you are using the right command, "java BigDebt" if your class is called BigDebt and the compiler produced a file named BigDebt.class. (This assumes that your source code doesn't start with a "package xxx;" line.) Your problem is likely a Classpath problem. Make sure you have CD'd to the directory where BigDebt is located. Then try:
    java -classpath . BigDebt

  • Problem using Java under Vista - Need help, please

    Hi everybody, I'm looking after a solution to resolve following problem : for one of my customer who's needing to use a secure access to a HTTPS URL, after Java is started, I receive the Java logo but it must be followed by an authentification screen where it's needed to enter a login + password. Sometimes it work (I think only when I force to reload the HTTPS certificate) but each time, the application freeze on this screen that I can see in the Task Bar but I can only close it and impossible to access it for the next step of the process. It's working on an original Windows Vista Home Premium pre-installed on a Sony Vaio Laptop and I've already use the application on another computer with Vista Business without any problem. Thanks in advance.

    Thanks for your answer. I've just tried on my XP Laptop. Here are the steps : after several windows, the Java start into a blank window and I receive then the logo at the left side of the window. After, in this case I'm asked to accept the HTTPS certificate and remember it if I want. When accepted, I receive then new "little" window (like a dialof box) with "Authentifaction request" when I need to enter again a login + password. If I recieve this last window, it mean that all is going fine but in my "problem" case, after the Java window, I see only this authentification request onthe task bar but no way to open it or to see it on the screen but no error message except ont the java window (no answer). Perhaps one more information, indication, it appaers "Oracle Application Server Forms Services" into the title bar.

  • Hi ...i need to maintain a personal record using JAVA ..so please help

    i need to store and display the personl records..
    import java.awt.event.*;
    import javax.swing.*;
    class PersonalOrganiser1 extends JFrame implements ActionListener
    JLabel l1 = new JLabel("NAME");
    JTextField tf1 = new JTextField(15);
    JLabel l2 = new JLabel("ADDRESS");
    JTextArea ta = new JTextArea(3,2);
    JLabel l3 = new JLabel("TEL NUM");
    JTextField tf2 = new JTextField(15);
    JLabel l4 = new JLabel("SEARCH");
    JTextField tf3 = new JTextField(15);
    JButton b1 = new JButton("ENTER");
    JTextField tf4 = new JTextField(15);
    JButton b2 = new JButton("RESET");
    b1.setBounds(100,150,70,50);
    b2.setBounds(100,170,90,40);
    b1.add(b1);
    b2.add(b2);
    b1.addActionListener( );
    b2.addActionListener( );
    public class Business
    JLabel l1 = new JLabel("NAME");
    JTextField tf1 = new JTextField(15);
    JLabel l2 = new JLabel("HOME ADDRESS");
    JTextArea ta = new JTextArea(3,2);
    JLabel l3 = new JLabel("OFFICE ADDRESS");
    JTextArea tb = new JTextArea(3,2);
    JLabel l4 = new JLabel("TEL NUM");
    JTextField tf2 = new JTextField(15);
    JLabel l5 = new JLabel("MOBILE NUM");
    JTextField tf3 = new JTextField(10);
    JLabel l6 = new JLabel("EMAIL-ID");
    JTextField tf4 = new JTextField(10);
    public class Friends
    JLabel l1 = new JLabel("NAME");
    JTextField tf1 = new JTextField(15);
    JLabel l2 = new JLabel("HOME ADDRESS");
    JTextArea ta = new JTextArea(3,2);
    JLabel l3 = new JLabel("OFFICE ADDRESS");
    JTextArea tb = new JTextArea(3,2);
    JLabel l4 = new JLabel("TEL NUM");
    JTextField tf2 = new JTextField(15);
    JLabel l5 = new JLabel("MOBILE NUM");
    JTextField tf3 = new JTextField(10);
    JLabel l6 = new JLabel("EMAIL-ID");
    JTextField tf4 = new JTextField(10);
    public class Doctor
    JLabel l1 = new JLabel("NAME");
    JTextField tf1 = new JTextField(15);
    JLabel l2 = new JLabel("HOME ADDRESS");
    JTextArea ta = new JTextArea(3,2);
    JLabel l3 = new JLabel("OFFICE ADDRESS");
    JTextArea tb = new JTextArea(3,2);
    JLabel l4 = new JLabel("TEL NUM");
    JTextField tf2 = new JTextField(15);
    JLabel l5 = new JLabel("MOBILE NUM");
    JTextField tf3 = new JTextField(10);
    JLabel l6 = new JLabel("EMAIL-ID");
    JTextField tf4 = new JTextField(10);
    class Kin
    JLabel l1 = new JLabel("NAME");
    JTextField tf1 = new JTextField(15);
    JLabel l2 = new JLabel("HOME ADDRESS");
    JTextArea ta = new JTextArea(3,2);
    JLabel l3 = new JLabel("TEL NUM");
    JTextField tf2 = new JTextField(15);
    JLabel l4 = new JLabel("OFFICE ADDRESS");
    JTextArea tb = new JTextArea(3,2);
    JLabel l5 = new JLabel("MOBILE NUM");
    JTextField tf3 = new JTextField(10);
    JLabel l6 = new JLabel("EMAIL-ID");
    JTextField tf4 = new JTextField(10);
    public void actionPerformed(ActionEvent ae)
    String str = ae.getActionCommand( );
    public static void main(String args[ ] )
    MyButtons mb = new MyButtons( );
    mb.setTitle("MY WEB PAGE");
    mb.setSize(500,400);
    mb.show( );
    this one class
    import javax.swing.*;
    import java.awt.event.*;
    class PersonalOrganiser extends JFrame implements ActionListener
    JLabel l1 = new JLabel("NAME");
    JTextField tf1 = new JTextField(15);
    JLabel l2 = new JLabel("ADDRESS");
    JTextArea ta = new JTextArea(3,2);
    JLabel l3 = new JLabel("TEL NUM");
    JTextField tf2 = new JTextField(15);
    JLabel l4 = new JLabel("SEARCH");
    JTextField tf3 = new JTextField(15);
    JButton b1 = new JButton("ENTER");
    JTextField tf3 = new JTextField(15);
    JButton b2 = new JButton("RESET");
    b1.setBounds(100,150,70,50);
    b2.setBounds(100,170,90,40);
    add(b1);
    add(b2);
    b1.addActionListener( );
    b2.addActionListener( );
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    class Business extends PersonalOrganiser
    class Friends extends PersonalOrganiser1
    public void actionPerformed(ActionEvent ae)
    String str = ae.getActionCommand( );
    public static void main(String args[ ] )
    MyButtons mb = new MyButtons( );
    mb.setTitle("My webpage");
    mb.setSize(500,400);
    mb.show( );
    }

    What are you doing ? Show this to your professor so he can seee what a failure he has been and so he can smack you.
    This is not java, I feel for you for the fact you actually typed all this out; either that or one of your classmates is playing a serious joke on you.
    forget about the visual stuff and create a class that can actually store and manipulate data first.
    this is probably too advanced and will make you cry but here goes
    public class Contacts implements serializable {
         public int search (String First, String Last) {
          //cycle throug htablemodel and check for first and last name
          //return row;   the row in TableModel the record was found at
         public String [] getRecord (int row) {
              int num_of_cols = records.getColumnCount();
               String [] temp = new String [num_of_cols];
                          for (int c = 0; c < num_of_cols; c++){
                            temp [c] = (String) records.getValueAt(row, c);
           return temp;  
        public void addRecord (String [] record) {
            records.addRow(record);
    public void save (String filename) {
            try {
                ObjectOutput out = new ObjectOutputStream(new FileOutputStream(filename));
                out.writeObject(this);
                out.close();
            } catch (Exception e) { e.printStackTrace(); }
    private javax.swing.table.DefaultTableModel records = new DefaultTableModel ();  //<-----this holds the data
    in your main() you use it like this
    File file = new File (filename);
    if (!file.exsists())  Contacts friends = new Contacts();
    else {
    try {
                    File file = new File(filename);
                    ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
                    // Deserialize the object
                    Contacts friends = in.readObject();
                    in.close(); return temp;
                } catch (Exception e) { e.printStackTrace();  }
    //this is where you would need a visual object to gather real data and plug it into the String [] array
    String [] friend = new String [3] = {"Joe", "Smith", "555-1212"};
    friends.addRecord(friend);
    String [] temp = friends.getRecord(friends.search ("Joe", "Smith"));
    //now you have data to display from file
    freinds.save("Freinds.dat");

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • Have tried to restore settings due to problems, now Iphone shows Sim Failure, how can I get back to using my phone? Please help, its a business phone. :(

    Hi, I have tried to restore settings on my Iphone due to problems I was having with the phone cutting out when talking on the phone, now Iphone shows Sim Failure, how can I get back to using my phone? Please help, its a business phone.

    Hi jclarke64, 
    Thank you for contributing to the Apple Support Communities. 
    I'm sorry to hear that your iPhone 4s was lost, and glad that you were able to upgrade. 
    If your iPhone 4s was backed up to iCloud or using iTunes, you can restore the backed up data to your new phone. 
    See the steps in this article for help with restoring from a backup:
    Back up and restore your iPhone, iPad, or iPod touch using iCloud or iTunes - Apple Support
    All the best,
    Jeremy 

  • TS3376 I was able to use the findmyiphone app last week, but now I have been getting an error message "Can't load findmyiphone.  There was a problem loading the application."  please help as we are trying to locate an ipod with pics of a no deceased loved

    I was able to use the findmyiphone app last week, but now I have been getting an error message "Can't load findmyiphone.  There was a problem loading the application."  please help as we are trying to locate an ipod with pics of a no deceased loved one.

    Had the same problem and the same message --  was suddenly unable to access icloud apps on my pc, also using Windows 7 and Internet Explorer. After several days of pulling my hair out, decided to try a different browser and was able to get in by using Firefox instead of Internet Explorer.  Hope this helps. 

  • Is there a Java utility class to help with data management in a desktop UI?

    Is there a Java utility class to help with data management in a desktop UI?
    I am writing a UI to configure a network device that will be connected to the serial port of the computer while it is being configured. There is no web server or database for my application. The UI has a large number of fields (50+) spread across 16 tabs. I will write the UI in Java FX. It should run inside the browser when launched, and issue commands to the network device through the serial port. A UI has several input fields spread across tabs and one single Submit button. If a field is edited, and the submit button clicked, it issues a command and sends the new datum to the device, retrieves current value and any errors. so if input field has bad data, it is indicated for example, the field has a red border.
    Is there a standard design pattern or Java utility class to accomplish the frequently encountered, 'generic' parts of this scenario? lazy loading, submitting only what fields changed, displaying what fields have errors etc. (I dont want to reinvent the wheel if it is already there). Otherwise I can write such a class and share it back here if it is useful.
    someone recommended JGoodies Bindings for Swing - will this work well and in FX?

    Many thanks for the reply.
    In the servlet create an Arraylist and in th efor
    loop put the insances of the csqabean in this
    ArrayList. Exit the for loop and then add the
    ArrayList as an attribute to the session.I am making the use of Vector and did the same thing as u mentioned.I am using scriplets...
    >
    In the jsp retrieve the array list from the session
    and in a for loop step through the ArrayList
    retrieving each CourseSectionQABean and displaying.
    You can do this in a scriptlet but should also check
    out the jstl tags.I am able to remove this problem.Thanks again for the suggestion.
    AS

  • TS3899 In my iPad 2 with IO6 today I can not send emails from my gmail account, they go to the outbox directly...why? How can i solve this problem? ..I restarted the IPad but the problem was not solved. Please help.

    In my iPad 2 with IO6 today I can not send emails from my gmail account, they go to the outbox directly...why? How can i solve this problem? ..I restarted the IPad but the problem was not solved. Please help.

    Greetings,
    Questions:
    1. What version of the Mac OS are you running (Apple > About this Mac)?
    2. What version of the iOS are you running (Settings > About)?
    3. Do you use MobileMe/ iCloud or another server based sync solution like Google or Yahoo?
    4. Do other changes to synced information like Address Book content sync successfully back and forth?
    Based on your description it sounds like you have a 1 way sync issue.  Events sync fine between the iOS devices and fine from the computer to the iOS devices but not from the iOS devices to the computer.
    Try:
    Backup your computer and iOS devices before doing anything else:
    http://support.apple.com/kb/HT1427
    http://support.apple.com/kb/ht1766
    Ensure all the devices in use are fully up to date: Apple > Software Update / Settings > General > Software Update
    Make separate backups of critical data:
    Backup your computer Addressbook: http://docs.info.apple.com/article.html?path=AddressBook/4.0/en/ad961.html
    Backup your computer iCal: http://support.apple.com/kb/HT2966
    Reset syncing on your Mac: http://support.apple.com/kb/TS1627
    Reply back if that does not resolve your issue.
    Hope that helps.

  • HI YANN/VADIM...Still having problem in BADIs...please help me out

    Hi Yann/Vadim,
    Facing a problem in BADI can u please help me out...
    I am implementing sourcing dashboard.
    I am facing problem while implementing the badi BBP_ECS_PO_OUT_BADI in SRM. and BBP_PO_INBOUND_BADI in R3.
    i have written following code in BBP_ECS_PO_OUT_BADI in SRM
    method IF_EX_BBP_ECS_PO_OUT_BADI~BBP_B46B_PO_OUTBOUND.
    data : ls_item type BBP_PDS_PO_ITEM_D.
    data : w_customer_fields type BBPS_IF_CUSTOMER_FIELDS_PI.
    move 'POITEM' to w_customer_fields-refobject.
    move 'CATALOGID' to w_customer_fields-fieldname.
    move ls_item-catalogid to w_customer_fields-container.
    append w_customer_fields to ct_bapi_customer_fields.
    endmethod.
    i have created field zsrmcatalogid field in R3 in EKPO table.and i am now implementing the Badi in R3 for BBP_PO_INBOUND_BADI .....in extended classic scenario.
    i have written following code in R3 BADI
    method IF_EX_BBP_PO_INBOUND_BADI~BBP_MAP_BEFORE_BAPI.
    data : wa_customer_fields type bbps_if_customer_fields,
    wa_bapi_te_mepoitem type bapi_te_mepoitem,
    wa_bapi_te_mepoitemx type bapi_te_mepoitemx,
    wa_extensionin type bapiparex.
    data : txt_960(960) type c.
    read table bbp_customer_fields into wa_customer_fields with key
    refobject = 'POITEM' fieldname = 'CATALOGID'.
    if sy-subrc eq 0.
    move wa_customer_fields-container TO
    wa_bapi_te_mepoitem-zsrmcatalogid.
    wa_bapi_te_mepoitemx-zsrmcatalogid = 'X'.
    endif.
    clear txt_960.
    clear wa_extensionin.
    write wa_bapi_te_mepoitem to txt_960 left-justified.
    wa_extensionin-structure = 'BAPI_TE_MEPOITEM'.
    wa_extensionin-valuepart1 = txt_960(240).
    wa_extensionin-valuepart2 = txt_960+240(240).
    wa_extensionin-valuepart3 = txt_960+480(240).
    wa_extensionin-valuepart4 = txt_960+720(240).
    append wa_extensionin to bapi_extensionin.
    clear txt_960.
    clear wa_extensionin.
    write wa_bapi_te_mepoitemx to txt_960 left-justified.
    wa_extensionin-structure = 'BAPI_TE_MEPOITEMX'.
    wa_extensionin-valuepart1 = txt_960(240).
    wa_extensionin-valuepart2 = txt_960+240(240).
    wa_extensionin-valuepart3 = txt_960+480(240).
    wa_extensionin-valuepart4 = txt_960+720(240).
    append wa_extensionin to bapi_extensionin.
    endmethod.
    But its not working...
    The PO details are not passed from SRM to R3.......
    PLEASE CAN U GIVE ME EXACT CODE FOR CHANGES TO BE MADE IN THIS BADI ..AS IT IS NOT WORKING...
    Can anybody help me regarding how to debug the BADI in R3.
    Thanks in Advance...

    Hi Ravi,
    You can transfer the standard SRM catalog ID field to R/3 tracking number field (if not already used for another purpose) in the R/3 PO.
    This will avoid to implement the R/3 inbound bapi.
    Here is an extract of the code.
    The ECS PO badi example was here used to transfer the unlimited delivery flag to R/3 PO for a Z combination of criteria as well as the transfer of <b>catalog ID</b> to <b>tracking number field</b> in R/3 PO :
    method IF_EX_BBP_ECS_PO_OUT_BADI~BBP_B46B_PO_OUTBOUND.
    update unlimited delivery flag in R3 PO for combination of vendor +
    Product Category maintained in the bespoke table ZUD_PC_VNDR ..
      LOOP AT ct_bapi_poitem INTO ls_bapi_poitem.
        lv_tabix = sy-tabix.
        IF ls_bapi_poitem-po_item IS NOT INITIAL.
          READ TABLE it_item INTO ls_item
               WITH KEY number_int = ls_bapi_poitem-po_item
                          del_ind    = ' '.
          IF sy-subrc = 0.
    Set Unlimited delivery Flag
            read table li_zud_pc_vndr into ls_zud_pc_vndr
                            with key partner       = ls_partner-PARTNER_ID
                                       category_id = ls_item-category_id.
            if sy-subrc eq 0.
              ls_bapi_poitem-UNLIMITED_DLV = 'X'.
            endif.
    Set the Dummy catalog.. entry..
            if ls_item-catalogid eq c_dummy.
              ls_bapi_poitem-TRACKINGNO = c_noncat.
            endif.
            ls_bapi_poitem-GR_BASEDIV = ' '.
            modify ct_bapi_poitem from ls_bapi_poitem index lv_tabix
                          transporting UNLIMITED_DLV TRACKINGNO GR_BASEDIV.
          ENDIF. "READ TABLE it_item ..
        ENDIF.   "IF ls_bapi_poitem-po_item ..
      ENDLOOP.   "LOOP AT ct_bapi_poitem ..
    endmethod.
    Kind regards,
    Yann
    PS : please do reward helpful answers ))

  • I have a really really big problem to my iphone icloud please help me i could send you my birth certificate for confirmation that im the real user please help me

         i have a really really big problem to my iphone icloud please help me i could send you my birth certificate for confirmation that im the real user please help me apple.corp and please tell me if this is not possible to be done it almost a month that i cant use my iphone.
         thank you for those who read this
    <Email Edited by Host>

    Remove your email address.  This is a public website, and you are addressing thousands of strangers.
    After doing that, tell us what your issue actually is.  This is a user-to-user technical forum.  You are not addressing Apple here.

  • Firefox is having problems with "Southwest Airlines website" Please help soon

    Whenever I go on Southwest Airline website, it does not work. I am having this problem since last month. Please help on this as soon as you can.

    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"
    Other things that need your attention:
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    * Shockwave Flash 10.0 r22
    * Java Plug-in 1.6.0_07 for Netscape Navigator (DLL Helper)
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://kb.mozillazine.org/Flash
    *http://www.adobe.com/software/flash/about/
    Update the [[Java]] plugin to the latest version.
    *http://kb.mozillazine.org/Java
    *http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)

  • TS1363 My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue?

    My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue? I have already updated to the latest version of iTunes on my Windows 8 and I cannot synchronize my iPod for the time being. Please do help me to solve this problem. Thank You.

    uninstall all iTunes,5 programes,this worked for me after reinstall them

  • When I plug my iPod into the computer, itunes won't come up on the screen and my iPod is not recognized anymore and it use to be. Please help because I can't sync it at all because it won't show up as a device

    When I plug my iPod into the computer, itunes won't come up on the screen and my iPod is not recognized anymore and it use to be. Please help because I can't sync it at all because it won't show up as a device on the right hand side of itunes.

    Try
    iOS: Device not recognized in iTunes for Windows
    I would start with              
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    or              
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    Before you reinstall the Apple software, also remove iCloud vi Control Panel Remove programs. The reinstall the Apple programs
    New cable and different USB port?
    Runs this and see if the results help with determine the cause
    iTunes for Windows: Device Sync Tests
    Try on another computer to help determine if computer or iPod problem

  • HT1335 My ipod classic have no software and I am stuck with it. It was formatted for apple but I use windows 8.  Please help. Thanks in advance.

    My ipod classic have no software and I am stuck with it. It was formatted for apple but I use windows 8.  Please help. Thanks in advance.

    Hello there, DrDhillon.
    The following Knowledge Base article goes over the steps that will help you resolve your issue:
    Restoring iPod to factory settings
    http://support.apple.com/kb/HT1339
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

Maybe you are looking for