Extremely Serious

Category: Windows (Page 2 of 4)

Generating PGP Keys with Gpg4win

Pre-requisite

Generating Keys

    1. Run the following command:
      gpg --full-gen-key
    2. Type 1 and press enter for the following question:
      Please select what kind of key you want:
         (1) RSA and RSA (default)
         (2) DSA and Elgamal
         (3) DSA (sign only)
         (4) RSA (sign only)
      Your selection?
    3. Press enter for the following question:
      RSA keys may be between 1024 and 4096 bits long.
      What keysize do you want? (2048)
    4. Press enter for the following question:
      Please specify how long the key should be valid.
               0 = key does not expire
            <n>  = key expires in n days
            <n>w = key expires in n weeks
            <n>m = key expires in n months
            <n>y = key expires in n years
      Key is valid for? (0)
    5. Type y and press enter for the following question:
      Key does not expire at all
      Is this correct? (y/N)
    6. Fill in the Real name appropriately and press enter.
    7. Fill in the Email address appropriately and press enter.
    8. The Comment is optional but don't forget to press enter.
    9. Type o and press enter for the following question:
      Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
    10. Fill-in the passphrase appropriately.

The output will be ending with something like the following:

pub   rsa2048 2019-11-27 [SC]
      8C99E30527B112D1CB6D646FE86A4FE7189AADC9
uid                      Real Name <real_email@email.com>
sub   rsa2048 2019-11-27 [E]

The second line is the PGP key ID. Thus from the output above. The key id is:

8C99E30527B112D1CB6D646FE86A4FE7189AADC9

Exporting Your Private Key

The my-secret-key.pgp file generated by this command can be use for signing your binaries.

Run the following command:

gpg --export-secret-keys <KEY_ID> > my-secret-key.pgp

DO NOT SHARE THIS FILE OR COMMIT TO YOUR REPOSITORY.

Publishing Your Public Key

Run the following command:

gpg --send-key <EMAIL_ADDRESS>

Use the email address you've used from generating the key.

Alternative way of Publishing your Public Key

  1. Generate an ASCII-armored PGP key using the following command:
    gpg --armor --export <EMAIL_ADDRESS>

    Use the email address you've used from generating the key.

    The preceding command is exporting your public key in ascii format.

  2. Copy and paste the generated public ID to the following address: http://hkps.pool.sks-keyservers.net/#submit
  3. Click the Submit this key to the keyserver! button.

Validating your Published Public Key

  1. You can validate the upload public key by placing your <EMAIL_ADDRESS> as a Search String from the following address: http://hkps.pool.sks-keyservers.net/#extract.

    This will only work if you submit your keys using the preceding section.

  2. Click the Do the search! button.

Deploy Function using Azure Functions Core Tools

Use the following command to deploy a(some) locally developed function(s) to azure function app.

func azure functionapp publish <AZURE_FUNCTION_APP>

Note: This command will only work if your terminal session was signed in to azure. The login using the command found here.

Where:

AZURE_FUNCTION_APP The name of the function app found in azure portal.

Capturing the Output of a Command to a Variable

Use the following for statement syntax with /f option

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]

    or, if usebackq option present:

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]

    file-set is one or more file names.  Each file is opened, read
    and processed before going on to the next file in file-set.
    Processing consists of reading in the file, breaking it up into
    individual lines of text and then parsing each line into zero or
    more tokens.  The body of the for loop is then called with the
    variable value(s) set to the found token string(s).  By default, /F
    passes the first blank separated token from each line of each file.
    Blank lines are skipped.  You can override the default parsing
    behavior by specifying the optional "options" parameter.  This
    is a quoted string which contains one or more keywords to specify
    different parsing options.  The keywords are:

        eol=c           - specifies an end of line comment character
                          (just one)
        skip=n          - specifies the number of lines to skip at the
                          beginning of the file.
        delims=xxx      - specifies a delimiter set.  This replaces the
                          default delimiter set of space and tab.
        tokens=x,y,m-n  - specifies which tokens from each line are to
                          be passed to the for body for each iteration.
                          This will cause additional variable names to
                          be allocated.  The m-n form is a range,
                          specifying the mth through the nth tokens.  If
                          the last character in the tokens= string is an
                          asterisk, then an additional variable is
                          allocated and receives the remaining text on
                          the line after the last token parsed.
        usebackq        - specifies that the new semantics are in force,
                          where a back quoted string is executed as a
                          command and a single quoted string is a
                          literal string command and allows the use of
                          double quotes to quote file names in
                          file-set.

For a very basic example, lets capture the result of the echo test to a variable. This can be done as follows:

for /f %I in ('echo test') do set OUTPUT="%~I"

Note: The echo test command here could be any executable command (e.g. executing a different batch or any executable file).

Reading a Batch Variable without the Quotes

Read a Batch Argument without the Quotes

This can be done by inserting a tilde (i.e. ~) character between the percent character and the corresponding argument position. 

For example for argument position 1 we can access it as the following:

%~1

Read a Batch Variable without the Quotes

This can be done with the following syntax:

%<VARIABLE_NAME>:"=%

Note: This is just using the replacement syntax as follows:

%<VARIABLE_NAME>:<FIND>=<REPLACE>%

« Older posts Newer posts »