diff --git a/sellar.bat b/sellar.bat new file mode 100644 index 0000000000000000000000000000000000000000..5a640fa9417c39f3eba02f19c66db32df510668e --- /dev/null +++ b/sellar.bat @@ -0,0 +1,51 @@ +@echo off +rem sellar.bat +rem sella un archivo en la BFA +rem Autor: Rafael Bidegain rbidegain@loteriadelaciudad.gob.ar +rem 04 de mayo de 2021 +rem Licencia GPLv2-only +rem Este script fue dessarrollado observando tsa2.sh de Robert Martin-Legene +rem + + +rem controlo la llamada al verificar.bat tenga un parametro +if [%1]==[] ( + echo falta el archivo para sellar + echo sellar file.xml + goto fin +) + +rem controlo el parametro corresponda a un archivo que existe +IF NOT EXIST %1 ( + echo no existe el archivo [%1] para sellar + goto fin +) + +rem elimino el archivo sha.txt usado en otra oportunidad +IF EXIST sha.txt ( + del sha.txt +) + +rem obtengo el hash sha256 del archivo y lo guardo en sha.txt +bin\sha256sum %1 | bin\awk "{print $1}" > sha.txt + +rem seteo la variable SHA con el hash sha256 del archivo +set /p SHA=<sha.txt + +rem controlo la variable SHA +if [%SHA%]==[] ( + echo fallo al generar el hash sha256. + goto fin +) + +rem creo el archivo sellar.json +echo {"hashes":["%SHA%"]} > sellar.json + +rem sello el archivo enviando el hash sha256 +bin\curl --header "Content-Type: application/json" --data @sellar.json https://tsa2.buenosaires.gob.ar/stamp + +rem envÃo un salto de linea a la consola +echo. + + +:fin \ No newline at end of file