The following program failed in verifying. Can somebody tell me where I am doing mistake... import java.io.*; import java.security.*; import java.security.interfaces.*; import sun.misc.BASE64Encoder; import java.security.spec.*; public class JCETest { public static void main(String[] args) throws Exception { FileReader fr = new FileReader("c:/ebmessage.xml"); BufferedReader br = new BufferedReader(fr); String message = ""; String record = ""; while((record = br.readLine()) != null) { record = br.readLine(); message+=record;
Murali, please update your display name to meet the requirements of JavaRanch. You must use you real first anme -space - your real last name. As to your question: You aren't using the signatures correctly. Let's think about what you are trying to do. You have a message and you want to verify that it came from Al Capone. Al Capone sends you his public cipher and a message that can only be generated with Al Capone's private cipher. You want to verify that the message that came in the clear is identical to Al's secret message. If they are then the original message really did come from Al and you can make your Valetine's Day plans. How to do that? Change this line: //dsa.update(sign); to dsa.update(messageBytes); happy encrypting!