How to include md5 package in application

Hi All,
First of all sorry I posted in another users thread. In the thread http://forums.sun.com/thread.jspa?threadID=5426671 the person used org.bouncycastle.crypto.digests.MD5Digest for doing md5.
I need some help here on how you include the org.bouncycastle.crypto.digests.MD5Digest library in my java code as I want to use the md5.
I am also working on something similar like that but without the web application part and a detail which consists on OTP part using md5.
As the md5() doesn't work in j2me so was also searching for something which will work on MIDP.
package com.abc; //package define
public class messDig5 //class define
    private String generateHash(String OTP, int loopNum) {
        byte[] secretBytes = OTP.getBytes();
        for (int x = 0; x < loopNum; x++) {
            byte[] tempStore = new byte[16];
            tempStore = hash(secretBytes);
            secretBytes = tempStore;
     //   return convertToHex(secretBytes);
        return byteArrayToHexString(secretBytes);
    public byte[] hash(byte[] secretBytes) {
       org.bouncycastle.crypto.digests.MD5Digest digest = new org.bouncycastle.crypto.digests.MD5Digest();
        digest.reset();
        // Update MD5 digest with user secret in byte format
        digest.update(secretBytes, 0, secretBytes.length);
        // get length of digest to initialise new md5 byte array
        int length = digest.getDigestSize();
        // create md5 byte array using length
        byte[] md5 = new byte[length];
        // calculate MD5 hash, using md5 byte array, 0 for buffer offset
        digest.doFinal(md5, 0);
        return md5;
//    private static String convertToHex(byte[] data) {
//        StringBuffer buf = new StringBuffer();
//        String Hex;
//        String formattedHex;
//        for (int i = 0; i < data.length; i++) {
//            int halfbyte = (data[i] >>> 4) & 0x0F;
//            int two_halfs = 0;
//            do {
//                if ((0 <= halfbyte) && (halfbyte <= 9)) {
//                    buf.append((char) ('0' + halfbyte));
//                } else {
//                    buf.append((char) ('a' + (halfbyte - 10)));
//                halfbyte = data[i] & 0x0F;
//            } while (two_halfs++ < 1);
//        Hex = buf.toString();
//        formattedHex = "\n" + Hex.substring(0, 4) + " " + Hex.substring(4, 8) + " " + Hex.substring(8, 12) + " " + Hex.substring(12, 16) + " " + Hex.substring(16, 20) + " " + Hex.substring(20, 24) + " " + Hex.substring(24, 28) + " " + Hex.substring(28, 32);
//        return formattedHex;
    static String byteArrayToHexString(byte byteValues[]) {
        byte singleChar = 0;
        if (byteValues == null || byteValues.length <= 0) {
            return null;
        String entries[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
            "a", "b", "c", "d", "e", "f"};
        StringBuffer out = new StringBuffer(byteValues.length * 2);
        for (int i = 0; i < byteValues.length; i++) {
            singleChar = (byte) (byteValues[i] & 0xF0);
            singleChar = (byte) (singleChar >>> 4);
            // shift the bits down
            singleChar = (byte) (singleChar & 0x0F);
            out.append(entries[(int) singleChar]);
            singleChar = (byte) (byteValues[i] & 0x0F);
            out.append(entries[(int) singleChar]);
        String rslt = new String(out);
        return rslt;

Camellia,
I take you already added bouncycatsle to your project as a compile dependency, since it compiles (unless it does not).
All you have to do for your code to work on the phone, you need to build your JAR file (that you use to distribute your MIDlet) with bouncycastle packaged in. This will all depend on the method you use to build your JAD and JAR files.
I use antenna tool, which provides me with ant tasks to compile, build jar, package external libraries etc. Your scenario can be different, but all you have to do is to search manuals and/or google for methods on how to package external libraries with your build.
Daniel

Similar Messages

  • How to include IHREP package?

    Hi Experts,
          The package IHREP is not available in our server. How to include that package?
    Regards
    K Arasu

    Hi
    Since this is a Std Package and the IW37N is a Std transaction, it should by default will come along with the std software?
    Which version of SAP are you working?
    In ECC6.0 it is there? may be you are working in Lower version of SAP?
    Chek whether IW37 is there or not? I think it will be there.
    Check with the Basis person for this..
    Regards
    Anji

  • How to include help file in application

    Hello,
    i developed an application using java swing. i need to include help file in my application. How to include it?
    Thanks,
    Sri

    Hi Sri,
    Use Java Help....
    There is some thing called as Help set. In a button action listener u have to call that.
    HelpSet helpSet = getHelpSet("path");
    HelpBroker helpBroker = helpSet.createHelpBroker();
    CSH.setHelpIDString (jButton,"filename");
    jButton.addActionListener(new CSH.DisplayHelpFromSource(helpBroker));
    Regards,
    Kumar

  • How to include aur packages in larch profile? [solved]

    Ive been recently making some live systems with larch and found it quite useful
    Im having problems with including software from aur (such as yaourt) in my livedvd. Is there a way to do this?
    Last edited by mafik (2009-02-18 21:24:54)

    Perhaps use yaourt to build each package from the aur that you want, then copy all those packages to a directory, and use the gen_repo command from the larch (larch/run/gen_repo) package to make that directory a custom repository. That's how I had to add the recompiled aufs package to my larch setup.
    Good luck!
    Scott

  • How to include vi dependencies in application builder?

    I have a small project in which I am trying to build an application.  I am having issues with the build including all dependencies.  In the project explorer "Items" tab, there are 7 files listed (1 dll and 6 vi's).  When I build the application, and try to run it on a different computer, it says it cannot find the dll and 3 of the 6 vi's.  Under "Source Files" for the build specifications, the only .vi I'm able to add is the main/startup vi.  It does not give me the option to add any of the vi's/dll that are listed as dependencies in the project explorer list.  Under "Source File Settings", when I click on dependencies, I have "Set destination for all contained items" checked and "Support Directory" selected.
    Any thoughts as to what I'm missing?
    Thanks,
    Jordan
    Attachments:
    ProjectExplorer.jpg ‏49 KB
    SourceFiles.jpg ‏51 KB
    SourceFileSettings.jpg ‏64 KB

    NeilR, let me know if this works for you.  
    Edited to add:  As I already pointed out, this isn't the cleanest code.  Especially some of the stuff more recently added.  It's pretty messy!
    Attachments:
    LabJackAnalogINwGPS142.zip ‏374 KB

  • How to include IW37N transaction?

    Hi Experts,
            The Enjoy transaction IW37 is not available in our server.But the transaction is available in another server. The transaction belongs to the package IHREP. How to include the package in our server?
    Please provide us your valuable suggestions.
    Regards,
    K Arasu.

    Hi
    Since this is a Std Package and the IW37N is a Std transaction, it should by default will come along with the std software?
    Which version of SAP are you working?
    In ECC6.0 it is there? may be you are working in Lower version of SAP?
    Chek whether IW37 is there or not? I think it will be there.
    Check with the Basis person for this..
    Regards
    Anji

  • How to include package

    sir
    i m running an mil application and i have an error in import javax.mail.*
    statement.that package does not exist
    how to include it in path.........
    plz help me out
    thank you
    gaurav

    hi,
    u need to have two jars,namely,mail.jar and activation.jar in your classpath
    to use the javamail apis.hope this is of any help
    bye,

  • How to include custom application.xml in JDev9i project

    Can anybody explain to me how to include a custom application.xml file when deploying to an .ear file? I need to include application wide security roles, and I can't see where in Jev9i how to do this.
    After searching this forum, I see that jdev9i can't include the orion-application.xml, but I want to include just the standard J2EE application.xml. Is this possible?
    Thanks,
    matt

    The standard application.xml file unfortunately can't be customized in JDev 9.0.2. The reasons why this capability was left out of JDev 9.0.2 are same reasons why the other EAR-level XML files were excluded. The OTN thread
    Re: Regarding 11i and E-business suite
    has a summary of those reasons, which you've probably seen. We know this is an area in need of improvement and will be adding this functionality in the JDev 9.0.3 release. Until then, you'll have to go with a work-around like an Ant build file, batch file, Java application, or some other kind of script.
    Below is a sample Java application which can be used to insert <security-role> elements into an EAR file's application.xml. Modify the main() method to customize for your purposes, and put xmlparserv2.jar on the classpath (in a JDev project, add the "Oracle XML Parser v2" library):
    package mypackage4;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    public class PostProcessEAR
    public static void main( String[] args ) throws IOException
    final String earFile = "C:\\temp\\myapp.ear";
    final PostProcessEAR postProcess = new PostProcessEAR( earFile );
    postProcess.addSecurityRole( null, "first_role" );
    postProcess.addSecurityRole( "Description for the second role", "second_role" );
    postProcess.commit();
    System.out.println( "Done." );
    private final File _earFile;
    private final ArrayList _securityRoles = new ArrayList();
    public PostProcessEAR( String earFile )
    _earFile = new File( earFile );
    public void addSecurityRole( String description, String roleName )
    if ( roleName == null )
    throw new IllegalArgumentException();
    _securityRoles.add( description );
    _securityRoles.add( roleName );
    * Write out modified EAR file.
    public void commit() throws IOException
    if ( _securityRoles.size() == 0 )
    return;
    final ZipFile zipFile = new ZipFile( _earFile );
    final Enumeration entries = zipFile.entries();
    final File outFile = new File( _earFile.getAbsolutePath() + ".out" );
    final ZipOutputStream out = new ZipOutputStream( new BufferedOutputStream( new FileOutputStream( outFile ) ) );
    while ( entries.hasMoreElements() )
    final ZipEntry entry = (ZipEntry) entries.nextElement();
    final InputStream in = zipFile.getInputStream( entry );
    if ( "META-INF/application.xml".equals( entry.getName() ) )
    final XMLDocument modifiedApplicationXml = insertSecurityRoles( in );
    final ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    modifiedApplicationXml.print( byteOutput );
    final int numBytes = byteOutput.size();
    entry.setSize( numBytes );
    if ( entry.getMethod() == ZipEntry.STORED )
    entry.setCompressedSize( numBytes );
    final CRC32 crc32 = new CRC32();
    crc32.update( byteOutput.toByteArray() );
    entry.setCrc( crc32.getValue() );
    out.putNextEntry( entry );
    byteOutput.writeTo( out );
    else
    // Copy all other zip entries as they are.
    out.putNextEntry( entry );
    copy( in, out );
    in.close();
    out.close();
    private XMLDocument insertSecurityRoles( InputStream in ) throws IOException
    final DOMParser domParser = new DOMParser();
    domParser.setAttribute( DOMParser.STANDALONE, Boolean.TRUE );
    try
    domParser.parse( in );
    final XMLDocument doc = domParser.getDocument();
    final Element docElem = doc.getDocumentElement();
    final Iterator iter = _securityRoles.iterator();
    while ( iter.hasNext() )
    final String desc = (String) iter.next(); // might be null
    final String roleName = iter.next().toString(); // must not be null
    final Element securityRoleElem = doc.createElement( "security-role" );
    if ( desc != null )
    securityRoleElem.appendChild( createPcdata( doc, "description", desc ) );
    securityRoleElem.appendChild( createPcdata( doc, "role-name", roleName ) );
    docElem.appendChild( securityRoleElem );
    return doc;
    catch ( SAXException e )
    e.printStackTrace();
    return null;
    private Element createPcdata( XMLDocument doc, String elemName, String pcdata )
    final Element elem = doc.createElement( elemName );
    elem.appendChild( doc.createTextNode( pcdata ) );
    return elem;
    private final byte[] buffer = new byte[4096];
    private void copy( InputStream in, OutputStream out ) throws IOException
    while ( true )
    final int bytesRead = in.read( buffer );
    if ( bytesRead < 0 )
    break;
    out.write( buffer, 0, bytesRead );

  • How to package Java application in a setup file?

    I wish to package my application in a setup file. On double clicking the icon of setup file, the installation of the application may begin. I like to include modified JVM, Acrobat Reader along with class files of the application (packaged in a JAR file) in the setup file, i.e., I want to spare users from the headach of downloading before installing the JVM or Acrobat Reader, etc.
    Things like this have been done in commercial products such as Dreamweaver.
    I have no idea right now how this can be done, but I have to work on this. Any hint, suggestion, direction, advise would be highly appreciated.

    This is a simple free program which will allow you to package your JVM etc with all your other files and it'll give you a small exe file which will invoke the VM and start your app. It only works on windows btw.
    http://www.rolemaker.dk/nonRoleMaker/javalauncher/marner_java_launcher.htm
    After you've set up the program all you need to do is download one the many shareware install programs from download.com. They're normally really easy to use, you just tell them the dir/s you want to package, which files, usually the exe, to add a shortcut to. It will then build a setup exe file for you.

  • How to compile and package my EJB application

    Hi,
    I just ran the sample programs from the Sun J2EE tutorial. Seems to work fine. I used the ant utility to compile all the programs and the J2EE Deployment Wizard to package and deploy everything. Now how do I compile and deploy a sample EJB program that I have written ?
    I am using the following platforms:
    1: JBuilder 3.0 : IDE (for writing the source code)
    2: JDK 1.4.0_01
    3: J2SDK EE 1.3.1 (EJB/Appln server)
    How do I make ant recognize my program and compile it... i guess the deployment procedure would still be the same.
    Can somebody please help me out on this ??
    Thanks
    prasanna

    Hi,
    Thanks for your prompt reply. I tried that out.. I have a directory called "customer" under which I have my interfaces,bean implementation class and the J2EE application client.
    ANT_HOME is set to : the directory where ant is installed
    JAVA_HOME is set to : the directory where JDK is installed
    J2EE_HOME is set to : the directory where J2EE server is installed
    and PATH : includes the bin directories of JDK, ant and J2SDK EE
    These are the paths I had to set when I ran the J2EE tutorial programs. It worked fine.
    Now when I say : ant myprogram I get an error saying:
    BUILD FAILED
    Target "myprogram" does not exist in this project
    How do I add my program also to the project so that ant can recognize it ?
    Also if there is any other way you can suggest to compile and package my application it would be great...
    Thanks
    prasanna

  • How to call a package from the Report in Oracle Application Express

    How to call a package from the Report in Oracle Application Express

    Hello,
    What do you mean? Something like SELECT mypackage.function( par1, par2) from dual?
    Or do you want to execute a procedure when something happens on the page, like clicking a button?
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • How to include html page or html code in adobeflex 4 web application please give me a solution.

                     How to include html page or html code in adobeflex 4 web application please give me a solution.
                       Thank you
                       Chandra Sekhar

    hi,
    go thru this link, may be of some help for you
    About IFrames
    http://www.deitte.com/archives/2006/08/finally_updated.htm
    IFrame Src
    http://code.google.com/p/flex-iframe/
    About the IFrame Approach
    http://www.deitte.com/archives/2008/07/dont_use_iframe.htm

  • [Solved] How to include examples for an AUR package

    Hi,
    I read the wiki pages how to create packages for the AUR,
    but I am not sure how to include examples which should be placed
    in /usr/share/doc/<package>/examples/ after the package was installed.
    Should all files be mentioned in the "sources" variable of the PKGBUILD
    or is it better to copy them via the .install file?
    Last edited by fana (2012-01-22 17:38:41)

    fana wrote:Ah, I see. So a good way would be just providing a tarball with all the examples and add that tarball to the source array
    Yup, I don't see how are these are examples different [1] from the other files.
    [1] Well, apart from stuff like https://bugs.archlinux.org/task/25998 ;P

  • [SOLVED]How to include a .Changelog file in a package?

    I want to include a .Changelog file in a package I'm building. But in the wiki, it only mentions that it could exist, and not how to include it.
    Someone knows how to do it?
    Last edited by mcsilva (2010-02-21 14:39:05)

    just put a file named `ChangeLog` in the same directory as PKGBUILD and makepkg
    Edit: wonder It did take me a minute to validate my assumption.
    Last edited by lolilolicon (2010-02-21 12:46:24)

  • How to include JAR file as package

    I am trying to code for passing data from an Applet to javascript. It appears the preferred method involves a package netscape.javascript to include support for the JSObject class. found a download of a jar file which contains this package. I am using Sun Creator and JCreator but dont know where to or how to install this package to be available to the compiler. Sorry for the beginner level question but any help is greatlyt appreciated. TIA

    You need to create a project and add the jar to the classpath. Then you can import the required libraries.

Maybe you are looking for

  • How to avoid Line Items(fields) in BAPI mapping.

    Hi Does any body help me for mapping between header and line items in BAPI.. my scenario is filerfcmail(wokflow)! File is CSV based : (ex: 001150,,1123,JERM,08122006,,,      ,,,ANN,,01082006, If you look at example csv file , there is some fields mix

  • CUE 8.6.1 Install

    Hi All, I've been tasked with installing and configuring CUE 8.6.1 on two routers.  I was able to install the software on both routers and install my licenses and get everything set up (integrated with CUCM).  One router works perfectly.  On the othe

  • IPad 2 and iPhone 4S not showing in iTunes 11.1.5

    Hi This might be a really common problem but searched before posting to avoid duplicating but just tried to put some new music on my iPhone 4S, running 7.1 and films on iPad 2 running same and nothing shows in iTunes v11.1.5. Normally this works over

  • Is it possible to customize like feature of sharepoint list?

    Hello, I want only like option in list ratings, if someone clicks on like then unlike link should not be visible. only positive ratings should be there.  Is it possible? if yes please help me. Thank You so much.

  • JAXB 2.0 validation when marshalling

    Hi, I'm using JAXB to marshall and unmarshall files. The issue i'm trying to address is that when a file is being marshalled - if a value is mandatory in the schema and if the user provides null value or something then shoulding this be a validation