@echo off
rem $Header: /home/cvs/src/go/crcheck/cr2gpg.bat,v 1.8 2025/10/14 11:39:12 ralph Exp $
rem Original Revision 2.2  2001/11/26 21:44:24  Administrator
rem Tested with gpg 1.4.22,23 (cygwin, not working) and 2.1.23, 2.2.27, 2.2.35(cygwin), 2.4.5,  2.4.7(win64)

echo ++=-------------------------------------------------------------------------=++
echo CR2GPG for CrCheck + GPG (GnuPG 2.x) driver MP Edition (c) by ROSE SWE, Ralph Roth
echo Multi-Platform Edition "$Id: cr2gpg.bat,v 1.8 2025/10/14 11:39:12 ralph Exp $"
echo ++=-------------------------------------------------------------------------=++

if exist CrCheck.asc del CrCheck.asc > nul
if exist CrCheck.txt del CrCheck.txt > nul
if exist CrCheck.txt.asc del CrCheck.txt.asc > nul
echo Validating (crc-checking) all the files in the current directory.

echo Please verify with GnuPG v2/PGP that this file has a valid signature! > CrCheck.txt
echo    gpg --verify CrCheck.txt >> CrCheck.txt
echo.>> CrCheck.txt
echo Then run CrCheck in this directory to verify >> CrCheck.txt
echo if files are missing, were added or are tampered >> CrCheck.txt
echo. >> CrCheck.txt


crcheck -create -hash blake3 >>CrCheck.txt
describe CrCheck.txt "Checksum file, run CrCheck and GPG to verify if tampered"
echo Signing+Validating now with (GNU)-PGP v2 (GPG must be in the PATH=... statement)

rem gpg 1.4.3: Invalid option "--clear-sign"
gpg.exe --clear-sign CrCheck.txt
echo Moving and touching (needs MOVE and TOUCH)

if exist CrCheck.txt.asc goto newdos

echo FOUND: CrCheck.txt [oldstyle]
if exist CrCheck.txt            copy /y CrCheck.asc CrCheck.txt >nul
goto olddos

:newdos
echo FOUND: CrCheck.txt.asc
if exist CrCheck.txt.asc        copy /y CrCheck.txt.asc CrCheck.txt >nul

:olddos
if exist CrCheck.asc del CrCheck.asc > nul
if exist CrCheck.txt.asc del CrCheck.txt.asc > nul


rem if you don't have rtouch (ROSE SWE)//touch (4Dos, Caldera/Dr.DOS, UNIX) remark this line out.

rtouch -eins CrCheck.txt
if exist CrCheck.txt.asc del CrCheck.asc > nul

