Курсовая работа: Анализ предметной области
return(info);
}
public static boolean CreateDigitalSignatureForFile(String puth)
{
try
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keyGen.initialize(1024, random);
KeyPair pair = keyGen.generateKeyPair();
PrivateKey priv = pair.getPrivate();
PublicKey pub = pair.getPublic();
Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
dsa.initSign(priv);
FileInputStream fis = new FileInputStream(puth);
BufferedInputStream bufin = new BufferedInputStream(fis);
byte[] buffer = new byte[1024];
int len;
while (bufin.available() != 0)
{
len = bufin.read(buffer);
dsa.update(buffer, 0, len);
}
bufin.close();
byte[] realSig = dsa.sign();
saveToFile (realSig,puth+".sig");
byte[] key = pub.getEncoded();
saveToFile (key,puth+".pubkey");
//byte[] priv_key = priv.getEncoded();