Best option to encrypt numerous files securely?
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Best option to encrypt numerous files securely?
unimportant.
Last edited by gemeenteraadslid on 2021-02-20, 12:37 UTC, edited 1 time in total.
Re: Best option to encrypt numerous files securely?
gemeenteraadslid,
In AHK it would be:
HTH
Roman
In AHK it would be:
Code: Select all
Loop, Files, C:\MyDataDir\*.*, FR
RunWait, <your_full_7-Zip_command_line_here_use_%A_LoopFileName%_as_file_name_placeholder>, %A_LoopFileDir%
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Re: Best option to encrypt numerous files securely?
snip.
Last edited by gemeenteraadslid on 2021-02-20, 12:37 UTC, edited 2 times in total.
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Re: Best option to encrypt numerous files securely?
snip.
Last edited by gemeenteraadslid on 2021-02-20, 12:37 UTC, edited 1 time in total.
-
- Power Member
- Posts: 872
- Joined: 2013-09-04, 14:07 UTC
Re: Best option to encrypt numerous files securely?
Why don't you just use a numeric counter for the file name instead of playing around with %RANDOM%?gemeenteraadslid wrote: 2021-02-18, 10:42 UTC Version with random file names. Collisions are possible, but unlikely.
If you don't care about the file names and their alphabetical order, a numerically increasing number sequence for the file names is as "meaningless" as any other random file naming scheme used to replace the "real" archive file names. By doing so, collisions are not just unlikely, they are impossible. (And as added bonus, your script would become a whole lot simpler, too...)
Re: Best option to encrypt numerous files securely?
If you already have the list of file, you can use tcbl and a dedicated ini command to launch for each file 7z command with password using counter with timestamp as output 7z file.
to call :
inside tcbl.ini file
--edit you can add header encryption to hide filename inside 7z archive -mhe=on
to call :
Code: Select all
cmd=<path to>\tcbl.exe
params:-i %L 7zEncrypt %T
Code: Select all
[7zEncrypt]
# Ask for password
ini=1 password ? pass: ?
#initial counter set to timestamp step 1
ini= $T 1
#call 7zip archive only with password
cmd=7z.exe a -mx=0 -p$_1 "$1$i.7z" "$f"
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Re: Best option to encrypt numerous files securely?
snip.
Last edited by gemeenteraadslid on 2021-02-20, 12:37 UTC, edited 4 times in total.
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Re: Best option to encrypt numerous files securely?
Just my opinion not asked for, snip.
Last edited by gemeenteraadslid on 2021-02-20, 12:42 UTC, edited 4 times in total.
Re: Best option to encrypt numerous files securely?
gemeenteraadslid wrote: 2021-02-19, 10:21 UTC And time consuming to find for average cmd scripters. So have fun ppl.
Well, that is rather condescending, isn't it?
Do you 'just' think lowly of the TC forum visitors or do you have a high opinion of yourself too?
OK, that answers that question ..
But that aside, I respond because of this part:
If you want this to be something where "average cmd scripters" can learn from:One can learn a lot from this simple script- For loops are generally on a higher pain level, and in this script, e.g. for the working errorlevel, Delayed Expansion and its special variable syntax IS CRUCIAL.
- Support for filemames containing spaces is lacking
- You are leaking the password - and other variables - to the calling environment
- There is no need to use enabledelayedexpansion. There are other, better (cleaner), ways. It certainly isn't CRUCIAL
- For almost every 'solution' you used, there is a better (simpler/ more reliable) way. A couple of examples:
- Instead of SET /A "COUNTER = !COUNTER! + 1", you can use
SET /A "COUNTER = COUNTER + 1" or even:
SET /A COUNTER += 1 - Use "" when defining varaibles to prevent trailing spaces to become part of the value:
SET "VARIABLE=value" - To read a passord from file, you use FOR /F "tokens=*" %%i IN ('type %PWFILE%') DO set pw=%%i
Alternative: set /p pw=<"%PWFILE%'" - ...
- Instead of SET /A "COUNTER = !COUNTER! + 1", you can use
Original messsage I responded to:
gemeenteraadslid wrote: 2021-02-19, 10:21 UTCNo special reasons, just for the lulz and it looks more evilelgonzo wrote: 2021-02-18, 12:21 UTCWhy don't you just use a numeric counter for the file name instead of playing around with %RANDOM%?
If you don't care about the file names and their alphabetical order, a numerically increasing number sequence for the file names is as "meaningless" as any other random file naming scheme used to replace the "real" archive file names. By doing so, collisions are not just unlikely, they are impossible. (And as added bonus, your script would become a whole lot simpler, too...). Yes I should do it as you say.
Here's a working solution with a counter. Encrypt files inline - in a folder recursively and just delete (not wipe) source files, commented out hre. BTW before someone mentions"uh oh pw in a file!!!11!" - yes, demonstration purposes, $wife support etc... I'm well aware of anYTHinG.
One can learn a lot from this simple script- For loops are generally on a higher pain level, and in this script, e.g. for the working errorlevel, Delayed Expansion and its special variable syntax IS CRUCIAL. And time consuming to find for average cmd scripters. So have fun ppl.
Code: Select all
REM Argument: Absolute path to a FOLDER echo off SET PWFILE=u:\Crypto\7zMSC.txt SET SEVENZIP=C:\Program Files\7-Zip\7z.exe FOR /F "tokens=*" %%i IN ('type %PWFILE%') DO set pw=%%i set COUNTER=0 setLocal EnableDelayedExpansion FOR /R %1 %%i IN (*) DO ( SET /A "COUNTER = !COUNTER! + 1" "%SEVENZIP%" a -mx=1 -mhe=on -p%pw% "%%~dpi!COUNTER!.7z" "%%i" REM IF "!ERRORLEVEL!"=="0" DEL /F /Q "%%~i" )
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Re: Best option to encrypt numerous files securely?
Is something wrong? Lowly/High opinion, wtf? I was rather enthusiastic about having found a solution and wanted to share. I thought it may help some people. But yeah, over the years of usenet and www I should have learned, posting solutions to self answered questions is something that should not be done.Well, that is rather condescending, isn't it?"One can learn a lot from this simple script
Do you 'just' think lowly of the TC forum visitors or do you have a high opinion of yourself too?"
Re: Best option to encrypt numerous files securely?
NotNull,
Hacker (Moderator)
I certainly did not read it as such. No need to assume the worst.Well, that is rather condescending, isn't it?
Hacker (Moderator)
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
-
- Junior Member
- Posts: 65
- Joined: 2011-11-28, 11:27 UTC
Re: Best option to encrypt numerous files securely?
I cann only talk for myself. In deleting anything I overreacted, that was childish, I apologize.