public void encrypt(String file, String encrypted_file, int size) throws Exception {
        FileInputStream input_file = new FileInputStream(file);
        FileOutputStream PGP_file = new FileOutputStream(encrypted_file, true);
        SecureRandom rnd = new SecureRandom();
        //session key k, must be 1<k<p-1
        BigInteger k;
        do
            k = new BigInteger(size, rnd);
        while (k.compareTo(p.subtract(BigInteger.ONE)) != -1 && k.compareTo(BigInteger.ONE) != 1);
        a = g.modPow(k, p);
        BigInteger m = new BigInteger(key.getEncoded());
        if (m.compareTo(p) == -1) {
            System.out.println("3DES Key: " + Utilities.getHexString(m.toByteArray()));
            ElgamalPKESKP keyPacket = new ElgamalPKESKP(key, a, y, k, p);
            keyPacket.dump(PGP_file);
            Des encryptor = new Des(key);
            encryptor.encrypt(input_file, PGP_file);
        } else System.out.println("Too big session key");
        input_file.close();
        PGP_file.close();
    }