echo off

set APK_SIGNER_JDK=c:\Program Files\Java\jdk1.8.0_162
set APK_SIGNER=%APK_SIGNER_JDK%\bin\jarsigner.exe
set PROVIDER=JCSPRSA
set STORE_TYPE=HSMDB
set KEY_ALIAS="Crypto-Pro Enhanced RSA and AES HSM Svc CSP####myRsaKey"
set APK_FILE=test.apk
set SIGNED_APK_FILE=test.signed.apk
set TRUST_STORE=trust_for_jar_signer
set PARAM=-J-Dkeytool.compat=true

echo "1. Signing apk:"
call "%APK_SIGNER%" %PARAM% -keystore NONE -storetype %STORE_TYPE% -storepass 1 -signedjar %SIGNED_APK_FILE% -digestalg CP_SHA256 -sigalg CP_SHA256withRSA -providerName %PROVIDER% -keypass "" %APK_FILE% %KEY_ALIAS%
echo "Signing apk completed."

pause

echo "2. Verifying signed apk:"
call "%APK_SIGNER%" %PARAM% -verify %SIGNED_APK_FILE%
echo "Verifying completed."

