Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@3F
Last active March 15, 2020 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3F/b7b7c8165948645edb7a868f9b9a6831 to your computer and use it in GitHub Desktop.
Save 3F/b7b7c8165948645edb7a868f9b9a6831 to your computer and use it in GitHub Desktop.
PublicKey from .dll or .snk or .pfx
@echo off
:: PublicKey <.dll or .snk or .pfx>
set file=%1 & set ext=%~x1
if not exist %file% goto notfound
if "%ext%"==".dll" (
call sn -q -Tp %file% || goto err
goto exit
)
if not "%ext%"==".snk" if not "%ext%"==".pfx" goto invalid
set pubkey="%~1_pubkey_%random%%random%%ext%"
call sn -q -p %file% %pubkey% || goto err
call sn -tp %pubkey% || goto err
goto exit
:cleanup
if defined pubkey if exist %pubkey% (
del %pubkey% /Q/F
)
exit /B 0
:notfound
echo File '%file%' was not found. 1>&2
exit /B 2
:invalid
echo Unsupported file type '%ext%'. Try with .dll; .snk; .pfx 1>&2
exit /B 1
:err
call :cleanup
echo Something went wrong 1>&2
exit /B 1
:exit
call :cleanup
exit /B 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment