Duplicating wincrypt algorithm in JAVA

Here is the background on this project: I am creating an automated licensing system for a company that sells telco products. Until now, they have been manually generating the activation keys using an exe program developed in house.
I have been hired to remove some of the manual interaction required from the employees, one of which is to automatically generate these activation keys. I emailed the developer of their exe about the algorithm he was using to generate the activation keys (based on serial number and hardware ID) because I need to duplicate that server-side. He said it probably wouldn't be possible because his program relies on wincrypt.
So my question is this: Is there any way at all to duplicate the wincrypt algorithm in JAVA? because i dont need that system to based on WINCRYPT, and using wincrypt.h will bound the user to have that file. I need to duplicate the wincrypt functionality exactly. Being off by even a little bit would render the script useless as it would generate invalid keys...
If anyone has any insight, I would love to hear it.
Sarwat
Edited by: Curgol on Jun 25, 2009 6:54 AM

Curgol wrote:
So you are saying that by using JCA/JCE i can have the same functionality that is being provided by wincrypt ?? i can implement the same encryption and decryption algorithm without being dependent on wincrypt.h and associated files ??
I know JCA/JCE packages provides encryption/decryption tools, but the problem is that i dont have any idea how wincrypt encrypt files, have it's cpp files though, but can the wincrypt functionality impolemented in JAVA ??.
Wincrypt from Microsoft is a library of hundreds of encryption related functions. The JCE defines an interface that providers provide implementations for. Just about everything in Wincrypt is available though one or more of the JCE providers.
There is no one encryption method provided by Wincrypt. If you are trying to match in Java an existing cryptographic process implemented using Wincrypt then you need to know exactly which of the Wincrypt algorithms (cipher, block mode, padding, key generation etc etc etc) is being used. Without this knowledge you are stuffed.

Similar Messages

  • Data Structures and Algorithms in java book

    Hi guys,
    I want to know a good book which is good for Data Structures and Algorithms in java. I am good at Core java but a beginner for Data Structures in Java. I am a little poor in Data Structures concepts.
    Following are the books I have found on the net. Could you help me the choose the best outta them.
    1. Data Structures and Algorithms in Java - Mitchell Waite
    2. Data Structures in Java - Sandra Anderson
    3. Fundamentals of OOP and Data Structures in Java - Richard Weiner & Lewis J. Pinson
    4. Object Oriented Data Structures Using Java - Nell Dale, Daniel T. Joyce, Chip Weems

    lieni wrote:
    I good data structures book doesn't have to be language-specific.Thx DrLazlo, my speachYes.
    The OP wrote:
    I have access to these books and dont know which one to start with.What I meant is that you shouldn't narrow your search to insist that the book you choose have "Java" in the title.

  • Classify and cluster documents with algorithm in java

    Hello everybody,
    I want to classify and cluster, let's say, 100 documents which are on the Intranet.
    I was thinking of including an algorithm in java who can do this.
    But i have no clue where to start of where to begin.
    Please give me some advice or maybe an example ;),
    Greetings,
    Thijs Leusink
    [email protected]

    I was thinking of including an algorithm in java who
    can do this.
    But i have no clue where to start of where to begin.Two steps:
    1. Find an algorithm that can do what you want.
    2. Write it in Java.
    Start with the first step: if you haven't done that yet, I don't think we can help you here. Possibly you could use Google to find an algorithm.
    Then go on to the next step: if you don't even know how to begin writing a Java program then there is a collection of introductory tutorials here:
    http://java.sun.com/docs/books/tutorial/
    If you are having problems after that, come back here and ask a specific question.

  • Quasi Newton Optimization Algorithm in Java

    I need to implement Quasi Newton Optimization Algorithm in Java, I�ve found it in C. Can anyone help me to find this in Java?

    Plagiarise in British English. Plagiarize in American English.
    These forums are used internationally, so either is reasonable.
    Don't correct other people's spelling unless you're really sure of your ground.

  • Different algorithms in Java

    What are the different algorithms in Java? Can someone list me each and its uses?

    Genetic Algorithm Method to Count Elephants:
    Have lots of babies. Wait till they're sixteen and
    throw them into Africa telling them to count
    elephants. After 1 year, have a family reunion and
    ask them to tell you how many they saw. Kill all the
    ones that didn't count as many as some threshold.
    Have the surviors have lots of kids, with each other.
    Have them repeat the process. Keep it up and it'll
    l converge to the right number, as long as they don't
    die from a horrible genetic disease.
    A. I don't think I can have babies. No uterus found. Pls advise.
    B. Your fitness function doesn't guarantee that your babies are counting unique elephants. Its not much help if your kids count the same elephant 1 billion times.

  • Announce: Generic Algorithms for Java, 0.3 release

    The latest release of jga: Generic Algorithms for Java is now available at
    http://jga.sf.net/
    Included in this release are a collection of algorithms adapted from STL that operate over generic collections and iterations. What's included are the algorithms that do not attempt to modify the collection/iteration that they're given: in other words, all of the find/search/count algorithms. Also included are the complete set of functors and predicates that were present in the last release, with a few modifications for easier use.
    The library is released under the LGPL, and includes the source for the library, the test framework, and a non-genericized version of the test framework that verifies that the library may be used without having the generic environment available.

    A (similar, it seems) parameterized collections library for JSR-14 Java.I had looked at JUtil some time ago, and I'm not sure of the similarity: JUtil looks to provide a number of interesting (if somewhat specialized) collections. JGA provides functors & predicates, and STL-ish algorithms that operate on collections and iterators. Looks to me to be more complimentary than similar.
    Mr. Ananian/Astaire's site is also the source of SinjDoc, the javadoc tool that I used to generate the javadoc at jga.sf.net, and with which I replaced the munge4doc.pl and mungedoclist.pl scripts that I had previously used and posted on this forum.

  • El Gamal Algorithm and Java problem

    I was trying to implement the El Gamal algorithm in java, but the problem is with the last part. I'm not getting the value of Message but according to algorithm i should get the value of message. Can anyone please tell me what did i do wrong?
    theory says, msg = x * (z^a)modInverse(p);
    import java.math.BigInteger;
    import java.math.*;
    import java.util.*;
    class ElGamel
         public static void main(String[] args)
              BigInteger p = new BigInteger("7747");
              BigInteger q = new BigInteger("3853");
              BigInteger a = new BigInteger("773");
              BigInteger k = new BigInteger("1193");
              BigInteger msg = new BigInteger("39");
              BigInteger y = new BigInteger("0");
              BigInteger x = new BigInteger("0");
              BigInteger z = new BigInteger("0");
              BigInteger temp = new BigInteger("0");
              BigInteger t2 = new BigInteger("0");
              int t1 = 0;
              y = q.modPow(a,p);
              System.out.println("Y is "+y);
              x = q.modPow(k,p);
              System.out.println("X is "+x);
              t1 = k.intValue();
              z = (msg.multiply(y.pow(t1))).mod(p);
              System.out.println("Z is "+z);
              t1 = a.intValue();
              x = x.pow(t1);
              temp = x.modInverse(p);
              msg = z.multiply(temp);
              System.out.println("Message is "+msg);
    }

    Reposting your code with markup. In future please use [code] tags, as you can see the effect it has on legibility: import java.math.BigInteger;
    import java.math.*;
    import java.util.*;
    class ElGamel
        public static void main(String[] args)
            BigInteger p = new BigInteger("7747");
            BigInteger q = new BigInteger("3853");
            BigInteger a = new BigInteger("773");
            BigInteger k = new BigInteger("1193");
            BigInteger msg = new BigInteger("39");
            BigInteger y = new BigInteger("0");
            BigInteger x = new BigInteger("0");
            BigInteger z = new BigInteger("0");
            BigInteger temp = new BigInteger("0");
            BigInteger t2 = new BigInteger("0");
            int t1 = 0;
            y = q.modPow(a,p);
            System.out.println("Y is "+y);
            x = q.modPow(k,p);
            System.out.println("X is "+x);
            t1 = k.intValue();
            z = (msg.multiply(y.pow(t1))).mod(p);
            System.out.println("Z is "+z);
            t1 = a.intValue();
            x = x.pow(t1);
            temp = x.modInverse(p);
            msg = z.multiply(temp);
            System.out.println("Message is "+msg);
    }

  • Search Algorithm in Java

    Hey Guys,
    I have written a crude search algorithm which extracts 4 fields from a database table into the String type of Java. Then this String object is tokenized and then within these tokens I search for the text the user has used.
    Once, I faced this problem that one of the String pulled from the DB was so huge that I got the OutOfMemory exception. Simple stating it, the text was so big that my system could not store all that text in one String object.
    I resolved this by adding more heap to java by doing:
    java -Xmx512M MySearchClass
    Now I am afraid that if there is another HUGE text in the DB , I can still run out of memory.
    Do I just need to get MORE RAM to my system and allot really huge heap space, such as 4 GB or so , so that if need be, the JVM can use it ?
    Suppose I get a server machine with 4 GB RAM, at some stage I'd still have an upper limit on the amount of text I can extract from the DB, right ?
    Is there any other way to stream the text from DB and then search ? Remember that I am tokenizing the text in the algorithm, so I think I can't use a buffer, or can I ?
    thanks a ton !
    -AZ

    These are SQL queries. I use SQL queries to pull out the text in the DB and then store it in a String object. The problem is that the text in DB can get so huge that the String object cannot hold it anymore due to memory limits. The JVM gets assigned a heap size and the size of the String object can get really big to exceed the heap size.
    I used : java -Xmx512M MySearchClass
    That assigned 512MB to the JVM so I haven't encountered the OutOfMemory exception so far. But my guess is that for some other data set, the String can be so big that even 512MB might not be enough.
    This search algorithm will be deployed on a server class machine with about 4 GB RAM. So we can give JVM 4GB heap space to use. But its a limitation again , right ?
    These text in DB are extracted from PDF files.

  • JPG to JBIG Algorithm in JAVA

    Hi!
    I need to do the jpg to jbg compresion. (http://www.jpeg.org/jbig/)
    This is a bi-level fax compresion. I don't find any solution for it...
    I was looking at Markus Kuhn source code in c (http://www.cl.cam.ac.uk/~mgk25/jbigkit/), but I'm still in school and I don't have the knowledge to rewrite it into Java...
    I need to make an applet for that conversation (i get a jpg picture), I'm trying with IMageMagick (http://www.yeo.id.au/jmagick/) and servlet right now (not pure programing solution ;))
    Is there some other algorithms?? Perhaps in java (without native code)?
    Thanks!

    Take a look at the ImageIO stuff in java 1.4 and later.
    This is a pluggable framework for loading and saving images. By default it can load and save jpeg and tiff (which has a
    fax compression mode I believe).
    If not then you can obtain thrid party plugins for the framework that support your format (or you can write your own).
    If you wish to perform tasks such as colour conversion (convert the image to binary for example) then you may want to
    look at JAI. However that is probably overkill. You can perform many simple image processing tasks using Java 2D.
    matfud

  • Standard Algorithms in Java

    Hello everone,
    does someone of you know a collection of standard algorithms programmed in Java where you can download the examples
    (a kind of library or documentation)
    We are trying to standardize our code (e.g. complex loops and conditions) and this would be a great help!
    thanks a lot
    Julian

    hi,
    sorry for the misty question.
    I searched of the solution of quite common programming
    problems .
    meant to find something like that but it should be a little
    bit more complex:
    http://www.acknowledge.co.uk/snippets/java/docs/
    thank you
    Julian

  • Developing a Payroll System with NSD - A simpler algorithm in Java?

    Hi,
    I've been trying to develop a payroll system but I'm having some challenges on "trapping" the Night Shift Differential for all shifts.
    I'm from the Philippines and our NSD starts from 10pm - 6am by law.
    This payroll system is supposed to accept any shifts: day or night; 8-hour shifts, more or less than 8-hour shifts... making it dynamic in a sense.
    I've tried to evaluate each possible shift by start time and end time against the NSD's start time and end time. The result is a lot of "if-else" statements and some deep nesting.
    I'd like to know if there's a simpler algorithm for this in Java to "trap" the NSD from 10pm - 6am no matter what shift that "intersects" with it? Just so to have lesser complexity and better maintainability.
    Thanks.

    morphian wrote:
    abillconsl wrote:
    morphian wrote:
    Not yet. I'm still working on the codes for computations.Where's the data? If it is not in a database, then where is it?I'm using test cases.Okay ... where was I going with my line of questioning? ... It is just this - if you know where your data is coming from and what form it is in, it can make a difference in how you proceed.
    If you are working on Payroll data, nowdays it makes sense to imagine some relational DB containing the data. If that is the case, then knowing the structure of that data is absolutely paramount.
    For example - I really can't imagine doing this with times of day. In a well conceived DB structure, employees would likely be assigned some employee classification, based on a coding structure of some kind ... NS, DS, FT, PT ... etc. This might be broken down further by other classifications such as Primary vs Secondary job, salaried vs hourly workers, earning codes, whatever.
    So rather than working with times, you'd find the classifications of your employees and them perhaps add their hours or whatnot.
    So you see, it makes all the difference.
    ~Bill

  • Looking for a simple example of the Minimax algorithm in java

    Hey everyone,
    I'm currently working on a Gameboy emulator program as a pet project, and for one of the game's I'd like for the enemy AI to use the Minimax algorithm, but I don't have any experience with it (or recursion in general, for that matter). Could anyone maybe post a simple example of how this algorithm works?

    WTF? I'm sure you can find plenty of examples on google. It's on you to take the time to go through them, study them, and, if you still don't understand something, post a clear, concrete question that indicates what you read and what you didn't understand about it.
    As is, you're essentially treating folks here as your research flunkies and saying, "Give me an example that's better than all the ones already easily available to me. Read my mind to know why I didn't like them."

  • Power load flow algorithms in Java

    I have a project in hand,its about implementing power alorgithms using java,and i am very new to java programming.I need help in this area.Is there anyone who has the experience in writting tutorial packages(eg for electrical topics)?
    thxk!

    P=I*E;
    Ummmm.... Pie

  • Social network algorithms in java

    hi all,
    can anybody help me, i want to develop an application like that of a myspace wherein it shows your friends and friends of your friends, in short social networking. I don't know how to implement this one. Or can somebody give me a simple example for this?!
    thanks in advance. Your help would be greatly appreciated. I just don't have any idea on how to start this.

    Sure
    package com.james_newbie.myspace.ripoff;
    public class MySpaceRipoff {
    // rest of code goes here
    }Do you seriously expect someone to post anything
    close to a complete social-networking website?Have
    you any idea how large a project that is? There's
    nothing that could be posted here that would be of
    any worth at all
    "I'm thinking of porting XFree86 to Java, could
    anyone give me an example of how to do this?".Argh,
    when will the outrageously-scoped demands for code
    end??thanks!!! you are of great help. all im asking is a
    little idea from you guysI am of great help. I'm helping you understand the futility of your question. There is no "little idea" to be had here, the project is too large in scope for us to give you anything of worth. You've not even bothered to come up with any requirements, all you've done is said "I want to rip off myspace. How do I do it?". How are we expected to answer that? Think about it, what is it you're actually asking? If you're just asking for "a little idea" that really means you don't know what you want to do, and need someone else to tell you exactly how to build a fairly large, complex website from scratch. Is that really something that can be answered in a forum?
    Don't fall into the typical newbie trap here, and get into a flame war because I didnt' fall over and give you exactly what you expected to hear. We see this happen every single day now, and it always ends the same way - you get no help, and ensure you probably never will because you were rude. Distinguish yourself from those other losers and realise you've asked a duff question

  • Compability problem with Java and Python  RSA algorithm implementation

    I have client server application. Server is writtein in python, client in java. Client receives messages from server encrypted with RSA (http://stuvel.eu/rsa), and I'm unable to decrypt it. It seems that this is RSA algorithm compatibility problem. I'm using algorithm from java.security package, instatinating Cipher object like this: c = Cipher.getInstance("RSA"); . I noticed that this algorithm produces for input blocks of lengtrh <=117 ouput block of length 128. Server I guess uses the most triviall impelentation of RSA ( (1 byte is encrypted to 1 byte) So i want to make my java algorithm compatibile with this one which server uses. How to do that ? Do i have to instatinate Cipher object in different way ? Or use another library ?

    azedor wrote:
    First you said it was no good because it could only handle <= 117 byte inputs, now you say it is no good because it produces a 128-byte output. You're not making sense.First i said that this two RSA implementations are not compatibile, and first reason i noticed firstly is that Python imlementation for input of length N produces cryptogram of the same length. Not true. In general, the RSA encryption of any number of bytes less than the length of the modulus will produce a result of length near that of the modulus. When N is less than the length of the modulus, it is rare that N bytes of cleartext produces N bytes of ciphertext.
    Java implementation for data block of length <=117 produces alwasy 128 bytes of output.Pretty much correct and very much desirable. This is primarily a function of the PKCS1 padding which is used to solve two basic problems. First, as I alluded to in my first response, it is the nature of the algorithm that leading zeros are not preserved and second when the cleartext is very small (a few bytes) the exponentiation does not roll over and it is easy to decrypt the result. Both these problems are addressed by PKCS1 padding.
    >
    >
    After what sabre150 said i think of giving up idea of translating Python code to Java and considering to use another assymetric cryptography algorithms on both sides. Can you recommend me sth what should be compatibile with Python ?This seems to be at odds with your statement in reply #3 "Also have acces only to client code so i have to change sth in java." ! This statement is why I said "I suspect ... you have dug a deep hole".
    In your position I would use the Python bindings for openssl. Once more, Google is your friend.

Maybe you are looking for