In the ZIP file password protection
Hi allI spoke of the code to create a zip file. Its working fine. Now, I want to add the password in this zip file. Can someone help me in there to achieve?
Zip code:
------------
import java.util.zip.*;
import java.io.*;
public class UTLZip
{
public static void compressFile(String infilename, String outfilename)
throws IOException
{
try
{
FileOutputStream fout = new FileOutputStream(outfilename);
ZipOutputStream zout = new ZipOutputStream(fout);
ZipEntry ze = new ZipEntry((new File(infilename)).getName());
try
{
FileInputStream fin = new FileInputStream(infilename);
zout.putNextEntry(ze);
copy(fin, zout);
zout.closeEntry();
fin.close();
}
catch (IOException ie)
{
System.out.println("IO Exception occurred: " + ie);
}
zout.close();
}
catch(Exception e)
{
System.out.println("Exception occurred: " + e);
}
}
public static void copy(InputStream in, OutputStream out)
throws IOException
{
byte[] buffer = new byte[4096];
while (true) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) break;
out.write(buffer, 0, bytesRead);
}
}
}
----------------------------------------------------------------
create or replace
PACKAGE "SSSL_FILE_ZIP"
IS
PROCEDURE compressFile (p_in_file IN VARCHAR2, p_out_file IN VARCHAR2)
AS
LANGUAGE JAVA
NAME 'UTLZip.compressFile(java.lang.String,
java.lang.String)';
END;
Thanks in advanceSan,
I have not tested the code with large files, it was just a quick hack.
Try to change the encrypt with this function
function encrypt( p_pw varchar2, p_src blob )
return blob
is
t_salt raw(16);
t_key raw(32);
t_pw raw(32767) := utl_raw.cast_to_raw( p_pw );
t_key_bits pls_integer := 256;
t_key_length pls_integer := t_key_bits / 8 * 2 + 2;
t_cnt pls_integer := 1000;
t_keys raw(32767);
t_sum raw(32767);
t_mac raw(20);
t_iv raw(16);
t_block raw(16);
t_len pls_integer;
t_rv blob;
t_tmp blob;
begin
t_salt := dbms_crypto.randombytes( t_key_bits / 16 );
for i in 1 .. ceil( t_key_length / 20 )
loop
t_mac := dbms_crypto.mac( utl_raw.concat( t_salt, to_char( i, 'fm0xxxxxxx' ) ), dbms_crypto.HMAC_SH1, t_pw );
t_sum := t_mac;
for j in 1 .. t_cnt - 1
loop
t_mac := dbms_crypto.mac( t_mac, dbms_crypto.HMAC_SH1, t_pw );
t_sum := utl_raw.bit_xor( t_mac, t_sum );
end loop;
t_keys := utl_raw.concat( t_keys, t_sum );
end loop;
t_keys := utl_raw.substr( t_keys, 1, t_key_length );
t_key := utl_raw.substr( t_keys, 1, t_key_bits / 8 );
t_rv := utl_raw.concat( t_salt, utl_raw.substr( t_keys, -2, 2 ) );
--
for i in 0 .. trunc( ( dbms_lob.getlength( p_src ) - 1 ) / 16 )
loop
t_block := dbms_lob.substr( p_src, 16, i * 16 + 1 );
t_len := utl_raw.length( t_block );
if t_len < 16
then
t_block := utl_raw.concat( t_block, utl_raw.copies( '00', 16 - t_len ) );
end if;
t_iv := utl_raw.reverse( to_char( i + 1, 'fm000000000000000000000000000000x' ) );
dbms_lob.writeappend( t_rv, t_len, dbms_crypto.encrypt( t_block, dbms_crypto.ENCRYPT_AES256 + dbms_crypto.CHAIN_CFB + dbms_crypto.PAD_NONE, t_key, t_iv ) );
end loop;
--
dbms_lob.createtemporary( t_tmp, true );
dbms_lob.copy( t_tmp, t_rv, dbms_lob.getlength( p_src ), 1, t_key_bits / 16 + 2 + 1 );
t_mac := dbms_crypto.mac( t_tmp, dbms_crypto.HMAC_SH1, utl_raw.substr( t_keys, 1 + t_key_bits / 8, t_key_bits / 8 ) );
dbms_lob.writeappend( t_rv, 10, t_mac );
dbms_lob.freetemporary( t_tmp );
return t_rv;
end;
Tags: Database
Similar Questions
-
I created a zip of a directory tree file using "send to...". "'Compressed (zipped) folder '. When I try to "extract all...". ", he asks me a password for some (not all) of the files in the zip file. I does not have a password for the zip file. I didn't even know it was possible to have a password on a specific file in a zip! Needless to say, I can not give the password because I don't know what it is.
I tried the following:
(1) created with "send to...". "Excerpt from" compressed (zipped) folder ', with 'extract all... '. ». Result: request password.
(2) created with "send to...". "" Compressed (zipped) folder ", extract with 7 - zip. Result: No password query. All the files extracted intact.
(3) created with 7 - zip, extract with "extract all...". ». Result: request password.
(4) created with 7-zip, extract with 7 - zip. Result: No password query. All the files extracted intact.What I find most interesting is (3).
Does anyone have an idea of what's going on? Is there some kind of security on the files meta-data that could / should cause this behavior?
System information:
XP Pro 2002 SP3 on MS network (I have no idea what server, etc..)
Hi ruborg,
Your Windows XP question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the forum TechNet for assistance:
http://social.technet.Microsoft.com/forums/en/itproxpsp/threads
Hope the helps of information.
-
I opened 2 emails that were in the folder spam from my email and that each contained an attachment zip 2 k and 3 KB. As I could not open directly in my email, I opened the zip files with the "open in" another app option. When you open the zip files at this other app asked me if I wanted to extract zip files in a new folder, I have accepted, in both files .js (javascript) files there. I opened these .js inside this same application files and content files white text on black background and that seems to be a script file. My question is: my iPad Air has been compromised by a scam of viruses, such as the Trojan horse thieves and banking password especially as Dridex or Dyreza, the Trojans and ransomware as Locky, cryptolocker, or Teslacrypt. If that were the case, then what is the solution to get rid of these... Thank you.
Simply delete them. It is not possible to install anything on iOS using this method. For good measure, you can remove and reinstall the application allowing you to open it with, but I don't really have that is actually needed.
-
Today, I downloaded a zipped file and the "extract all" option is missing? When I double click, it doesn't open the program the zipped file is supposed to play in (i.e - iTunes, Windows Media Center), but nothing does not appear or play? What should I do?
Hi LadyJ03,
Make sure that the downloaded file is not corrupted.
Important The method below mentioned steps show you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:
How to back up and restore the registry in Windows
322756 (http://support.microsoft.com/kb/322756)You can perform the steps described below and check if it works.
Restore and return the file Association in Windows Vista if Original
1. click on Start and then type regedit in the start search and press ENTER.
2. navigate to the following registry branch:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ [ext]
Replace the [exe] with the real extension of the file you want to restore the file type association to return to the default Windows Vista original. If you are not sure, simply browse through all the Sub-touche under FileExts.
3. delete the subkey named UserChoice.
4. exit the registry editor.
For more information, please visit the following links:
Compress and uncompress files (zip files)
http://windowshelp.Microsoft.com/Windows/en-us/help/7050d809-c761-43d4-aae7-587550cd341a1033.mspx
Hope this information is useful.
Boumediene. K.
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think.If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.
-
When I try to convert a pdf to Word, it is said the document is password protected and the Word option is gray.
Probably, give up. But
* If you HAVE the password you can remove it with Acrobat Pro
* You can ask the creator of the document for a file unprotected
Sometimes passwords are automatically added and doesn't know not, for example, some banks. There is no solution.
-
How to save a file password protected without password?
Someone sent me a file protected by password and I want to save it on my computer without the password.
Thank you
Scott
Hi Scott,.
It is not possible to save a file password protected without password with Adobe Reader, need you Adobe Acrobat to remove protection by password. Even with Adobe Acrobat, you can only remove the safety if you are informed on the password otherwise you will need to contact the author / creator of the PDF to remove security.
Kind regards
~ Dominique
-
Windows Media Player won't play the .zip files. How to see or play these files?
Media Player
Windows Media Player won't play the .zip files. How to see or play these files? I'm 67 and not tech savvy thanks for the help.Hello
ZIP files are compressed, so you need to unzip and then play the content if the
content is of type WMP files.Compress and uncompress files (zip files)
http://Windows.Microsoft.com/en-GB/Windows7/compress-and-uncompress-files-ZIP-filesI hope this helps.
Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="">-><- mark="" twain="" said="" it="">->
-
How can I disarm the zipped files
When I send a photo or a file attached in my e-mails, ITI has an option for the recipients to click on the zipped files, and he shows them ALL my pictures and files that I DON "T want everyone to see. I was just trying to send them a photo. HOW TO DLETE THIS ZIPPED FILE?
Hello
1. what email provider do you use?
I would do the following:
a. right-click on the zipped file and select extract all.
(b) after they are extracted, except those that you don't want others to see on your hard drive (make a folder) and set the one you want to send as an attachment. -
Could not open the zipped file
Original title: I can't open my file are compressed, I think they are embroidery designs?
I put the drawings in my doc file, I see what looks like a file but cannot open the same try to put in the folder and open. I don't know what is a compressed file, but I saw that while I'm going to lower the load, don't know if I did something a way to use it or not.
Hello
You have any software to open Zip files?
To inform you, a zip file contains one or more of the files that have been compressed to reduce the size of the file, or stored as is. The zip file format allows a number of compression algorithms. Zip files generally use file extensions ".zip" or ".". ZIP ".
You will need third-party software to open ZIP files in Windows XP. Use your favorite search engine to download third party software.
Note: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.
I hope this information is useful!
-
I can't extract the zip files; I get an error message that says: "Application not found". When I check help & press the Start button, it tells how to do it. I thought a program to automatically extract compressed files came with Vista.
Hello
1. you use the functionality of Windows Vista to unzip file or third party software?
2. have you done any software or hardware changes on your computer before this problem?
To work with this problem, see the following methods.
Method 1:
Scan of the SFC
Refer to this article for more information on how to use the System File Checker tool to fix the system files missing or corrupted on Windows Vista or Windows 7.
http://support.Microsoft.com/kb/929833
View the results of the analysis.
Method 2:
Run the fixit from following link.
Difficulty of broken desktop shortcuts and common system maintenance tasks
http://support.Microsoft.com/mats/system_maintenance_for_windows/en-usIn addition, I suggest you to check if the .zip file has been associated with a particular program in the section default programs.
http://Windows.Microsoft.com/en-us/Windows-Vista/change-which-programs-Windows-uses-by-default
Check if it helps.
-
Cannot extract the zipped files
I can't extract the zipped files. An audio file on my desktop as one. MP3.zip file, and when I right click on it, there is no option to extract the file. I have compressed folders that contain pictures and tried to unzip them without success. There is no option in the menu "right click" to extract the selected file. My windows lack extraction or unzipping option? Help, please!
Hello
Maybe the file is not a real. ZIP file - try to download another. ZIP and save it - so go ahead and
Click right on and see if there is an option/unzip Unzip (unpack). If yes then you must check with
the site where you got the. MP3.zip file to see how to handle. Maybe rename it to filename.mp3
HOWEVER filename.zip will work.Download this small utility which is very convenient and comes in. ZIP format just to see if your. ZIP functions
actually work. You can keep the utility or delete, it requires no installation and is very low.What is there in the Startup - free
http://www.NirSoft.NET/utils/what_run_in_startup.htmlDownload - SAVE - go where you put it - right click on and search for decompress/unzip options.
==================================
IF you have ZIP 3 1 problem here you should fix it up:
How to restore Vista built-in ZIP files Support
http://www.Vistax64.com/tutorials/65254-zip-file-support-restore.html
How to enable or disable the files compressed in Vista
http://www.Vistax64.com/tutorials/93827-zip-file-compressed-folders.html
Restore the Type Associations by default Vista file extensions
http://www.Vistax64.com/tutorials/233243-default-file-type-associations-restore.html---------------------------------
How Unassociate a Type of Extension file in Vista - and a utility to help
http://www.Vistax64.com/tutorials/91920-unassociate-file-extention-type.html
Restore and return the file Association in Windows Vista if Original
http://www.mydigitallife.info/2008/06/22/restore-and-reset-file-association-in-Windows-Vista-back-to-original-default/Reset and Fix Broken Windows Vista file Ext and Type Associations (include EXE, COM, SYS, ZIP, LNK,
Folder, drive)
http://www.mydigitallife.info/2008/06/22/reset-and-fix-broken-Windows-Vista-file-ext-and-type-associations-include-exe-com-sys-zip-lnk-folder-drive/For Windows Vista file association problems
http://www.Winhelponline.com/articles/105/1/file-association-fixes-for-Windows-Vista.htmlI hope this helps.
Rob - bicycle - Mark Twain said it is good.
-
I am trying to extract a zip file I downloaded, but the option extract is no longer there. I did so many times in the past with no problems. The icon is also different, where it helps to have a folder with a zipper, it is now a white square with a picture of a computer inside. I tried everything... someone please help!
Hello
Can you work with other ZIP files? If Yes, then this file is not a real ZIP file or it is damaged.
Check with the source.---------------------------------------------------------------------
If you have problems with all the ZIP files, that they should contribute:
Do a Restore Point to use in case you make a mistake, then you can skip a few steps.
How to create a Vista System Restore Point
http://www.Vistax64.com/tutorials/76332-system-restore-point-create.htmlIf you need later:
How to make a Vista system restore
http://www.Vistax64.com/tutorials/76905-System-Restore-how.html----------------------------------------------------------------------------------------
Now you can skip exports
Click the start Orb - type in the area of search-> regedit - continue click on user account control
Go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.zip
Click on the drop down arrow to the left of the file .zip
Right-click on OpenWithList
Click on delete
Click Yes
Right-click UserChoice
Click on delete
Click Yes
Exit regeditYour .zip files should now open with the native compression/decompression system that comes with Windows Vista.
=======================================================================
If necessary:
How to restore Vista built-in ZIP files Support
http://www.Vistax64.com/tutorials/65254-zip-file-support-restore.htmlHow to enable or disable the files compressed in Vista
http://www.Vistax64.com/tutorials/93827-zip-file-compressed-folders.htmlRestore the Type Associations by default Vista file extensions
http://www.Vistax64.com/tutorials/233243-default-file-type-associations-restore.html---------------------------------
How Unassociate a Type of Extension file in Vista - and a utility to help
http://www.Vistax64.com/tutorials/91920-unassociate-file-extention-type.htmlRestore and return the file Association in Windows Vista if Original
http://www.mydigitallife.info/2008/06/22/restore-and-reset-file-association-in-Windows-Vista-back-to-original-default/ Reset and difficulty Broken Windows Vista file Ext and Type Associations (include EXE, COM, SYS,
ZIP, LNK, folder, drive)
http://www.mydigitallife.info/2008/06/22/reset-and-fix-broken-Windows-Vista-file-ext-and-type-associations-include-exe-com-sys-zip-lnk-folder-drive/For Windows Vista file association problems
http://www.Winhelponline.com/articles/105/1/file-association-fixes-for-Windows-Vista.html=====================================
7-zip is a free alternative, and it has a forum to help:
7-zip
http://www.7-zip.org/7-zip - Forums
http://sourceforge.NET/projects/sevenzip/Forums/Forum/457977-zip - Support
http://www.7-zip.org/support.htmlI hope this helps.
Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">->
-
How to open the zipped files?
How to open the zipped files?
Right-click | Extract all.
If these are RAR files, then you need a tool like this.
Free RAR Extract Frog
http://download.CNET.com/free-RAR-extract-frog/3000-2250_4-10804840.html -
Windows Photo Gallery does not open the zipped files
Photo Gallery Windows does not open the photos that are in the zipped files received by Email. He said: Photo Gallery can't open this photo or video. This file format is not supported, or you do not have the latest updates to the photo gallery.
This is expected behavior...
Unzip the file and open the uncompressed version. Or just open
the zip files and do drag the photos on the zip file and
drop in a new folder.then you can open. -
When I download compressed files, they go to the local level > temp location, when I extracted all the files, they are sent to the My Documents folder. Can I go to local > temp location and delete the zip file? Knowing that I still have the data in the My Documents folder.
Once they are checked, of course. If you want to keep a backup, you can move the zip file in your documents folder.
In fact, you can delete everything in the temporary folder that is not currently in use. Best time to do this removal is immediately after the start, before launching other applications.
Maybe you are looking for
-
missing multimedia controller driver?
I have a laptop hp pavilion dv5-1221tx... recently I upgraded my computer laptop windows vista home edition premium---> windows 7 Ultimate edition... the problem is that, although I have downloaded all the drivers supplied by hp via internet, but sti
-
Retriving former opus after wipe system
I had recently wiped my computer because if a bad virus and now I canoe get my origanal op back (vista) system I put hp about it and I was wondering is there any way I can recover Vista because xp is really not for me.
-
Printer Migration (XP to Win 7)
Hello I have a stand alone PC XP with a printer directly connected to it.I have have just branch PC Win 7 and want to migrate the printer (and settings) for her to the XP machine. I know that MS has a for Win 7 for Win 7 migration tool, but how do I
-
BlackBerry Z10 please help stop: find one in your city
Hello Since 3 days I have a problem on my Z10 I always get a notification saying: find one in your city and also that sends me to a site of meetings (xapush.com) I also mention announcement by barcode This request was withdrawn 2 days ago, but I stil
-
ONS 15454 presents itself as 'unknown' after power failure
We had a power failure that also landed an ONS 15454 in a remote installation. To restore power and power on the device, it appears in the CTC under gray with "Uknown2" as the name. I had someone reinsert the card of STC, but sometimes still unknown.