optimista
optimista

Reputation: 824

Generate digital signature of a file

I'm currently trying to make an application which could digitally sign any kind of document. I have declared the class GenSig according to this tutorial. However in my application there should be GUI for a file input. So I have;

File file = jFileChooser2.getSelectedFile();

FileInputStream fin = new FileInputStream(file);
byte fileContent[] = new byte[(int)file.length()];
fin.read(fileContent);            

String strFileContent = new String(fileContent);           

GenSig gensig = new GenSig();        
GenSig.main(strFileContent); 

It's throwing me an error on line GenSig.main(strFileContent); Where the variable should be String[] args according to whole source of GenSig class so I can't compile the application. I assume that the problem is in the type of string, it's not array, but I don't know which array, which variable from File object, I've declared on firts line, I need to use as input.

I know I'm doing something wrong, unfortunately in Java I'm just beginner so I need help a bit.

Upvotes: 0

Views: 4583

Answers (1)

Perception
Perception

Reputation: 80603

If you are following the tutorial to the letter then you should be passing the name of the file to be 'signed', as an argument:

final File file = jFileChooser2.getSelectedFile();
GenSig.main(new String[] {file.getAbsolutePath()});

Note, you don't actually need to create an instance of your GenSig class, since you are calling the main method statically.

Upvotes: 1

Related Questions