I have been working on a project to password protect the files generated by Oracle forms and reports. Since this will only be for internal users, I have used PDFUSER, PDFOWNER utilities given by Oracle.
The next tasks is to password protect the files generated by UTL_FILE. I tried to create job which zip the file and password protect it, however the idea was rejected citing performance issues because currently the files are being generated in txt and excel format.
BEGIN
dbms_scheduler.create_job(
job_name => 'TEST_PASS_ZIP',
job_type => 'EXECUTABLE',
job_action => '/bin/sh',
number_of_arguments => 1,
enabled => FALSE -- Test run only
);
dbms_scheduler.set_job_argument_value(
job_name => 'TEST_PASS_ZIP',
argument_position => 1,
argument_value => 'zip -P MySecret123 /win/Class2/SysGenRpt/FIN/testfile_password.zip /win/Class2/SysGenRpt/FIN/testfile_password.txt'
);
dbms_scheduler.enable('TEST_PASS_ZIP');
END;
/I found that using
https://github.com/antonscheffer/as_zip, we can zip the file. However, I am seeking answer where I can password protect the file at the time of file generation and user can simply open the file by providing the password. Not applying DBMS_CRYPTO as user cannot decrypt the file.
Anton's package allows adding a password to the zip file, eg
SQL> declare
2 l_txt blob;
3 l_zip blob;
4 begin
5 dbms_lob.createtemporary(l_txt,true);
6
7 l_txt := to_blob(bfilename('CTMP','ocw_file_list25.txt'));
8
9 as_zip.add1file( l_zip, 'ocw_file_list25.txt', l_txt, p_password=>'password' ); <<<<======
10
11 as_zip.finish_zip( l_zip, 'Zipfile containing one file with uncompressed size of '
12 || dbms_lob.getlength( l_txt ) || ' bytes' );
13
14 dbms_lob.freetemporary( l_txt );
15
16 as_zip.save_zip( l_zip, 'CTMP', 'myzip.zip' );
17 dbms_lob.freetemporary( l_zip );
18 end;
19 /
PL/SQL procedure successfully completed.
Isn't that what you're after?