<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>LINICKX.com</title><link>https://www.linickx.com/</link><description></description><lastBuildDate>Fri, 30 Jun 2017 15:11:00 +0100</lastBuildDate><item><title>PowerShell: A simple script to GPG encrypt files</title><link>https://www.linickx.com/powershell-a-simple-script-to-gpg-encrypt-files</link><description>&lt;p&gt;Recently I've needed to backup some sensitive files to online storage; my requirement was simple: work on local files and when they change encrypt. As I'm working on a windows machine that means powershell, I could schedule a task but I'm just manually running this as and when I need... I'm sure there's a better way, but this will do for now!&lt;/p&gt;
&lt;p&gt;Before you start you need &lt;a href="https://www.gpg4win.org"&gt;GPG4Win&lt;/a&gt; as this script is just a wrapper for the pgp2.exe. If you've not used GPG4Win before you will need a key, in GPG4win land they call this &lt;a href="https://www.gpg4win.org/doc/en/gpg4win-compendium_12.html"&gt;Creating an OpenPGP Certificate&lt;/a&gt;... do that and take note of the email address you choose, it's important for the script.&lt;/p&gt;
&lt;p&gt;Next create &lt;code&gt;encrypt_these_files.ps1&lt;/code&gt; in the folder that you want to back up, with this content:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Variables, change these.
$gpg_r = &amp;quot;me@here.com&amp;quot;
$gpg_prog = &amp;quot;${env:ProgramFiles(x86)}&amp;quot; + &amp;quot;\GNU\GnuPG\pub\gpg2.exe&amp;quot;
$destination = &amp;quot;C:\Users\nick\DropOneDriveBox\encrypted\&amp;quot;

# simple gpg wrapper
function gpg_me {
  $in_file = $args[0]
  $out_file = $args[1]
  #Write-Host $in_file &amp;quot; | &amp;quot; $out_file
  &amp;amp; $gpg_prog --yes -e -r $gpg_r -o $out_file $in_file
}

# Loop thru current directory.
$items = Get-ChildItem -Path &amp;quot;.\&amp;quot;
foreach ($item in $items)
{
      # if the item is NOT a directory, then process it.
      if ($item.Attributes -ne &amp;quot;Directory&amp;quot;) {
        $thepath =  $destination + $item.Name + &amp;quot;.gpg&amp;quot;
          If (Test-Path $thepath){
            # // File exists
            $ThisDate = $item.LastWriteTime
            $OtherDate = (Get-ChildItem -Path $thepath).LastWriteTime
            #Write-Host $item.Name &amp;quot; - This:&amp;quot; $ThisDate &amp;quot;Other:&amp;quot; $OtherDate
            If ( $ThisDate -gt $OtherDate) {
              Write-Host $item.Name &amp;quot;Needs updating..&amp;quot;
              gpg_me $item.Name $thepath
            }
          }Else{
            # // File does not exist
            Write-Host &amp;quot;Encrypting New File &amp;quot;  $item.Name
            gpg_me $item.Name $thepath
          }

      }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At the top of the file, change the &lt;code&gt;$gpg_r = "me@here.com"&lt;/code&gt; to your email address (used in the OpenPGP &lt;em&gt;Certificate&lt;/em&gt;) and change &lt;code&gt;$destination = "C:\Users\nick\DropOneDriveBox\encrypted\"&lt;/code&gt; to whatever folder you want.&lt;/p&gt;
&lt;p&gt;If you've not run any powershell scripts then don't forget to &lt;a href="https://stackoverflow.com/a/10638"&gt;set your execution policy&lt;/a&gt; before you &lt;a href="https://stackoverflow.com/a/2035209"&gt;execute the script&lt;/a&gt; &lt;code&gt;.\encrypt_these_files.ps1&lt;/code&gt; .&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nick Bettison</dc:creator><pubDate>Fri, 30 Jun 2017 15:11:00 +0100</pubDate><guid isPermaLink="false">tag:www.linickx.com,2017-06-30:powershell-a-simple-script-to-gpg-encrypt-files</guid><category>PowerShell</category><category>Windows</category><category>GnuPG</category><category>Encryption</category><category>Security</category></item><item><title>Seahorse is running in insecure memory.</title><link>https://www.linickx.com/seahorse-is-running-in-insecure-memory</link><description>&lt;p&gt;&lt;a href="http://www.gnome.org/projects/seahorse/"&gt;Seahorse&lt;/a&gt; is a cracking
&lt;a href="http://www.gnupg.org/"&gt;GnuPG&lt;/a&gt; implementation for
&lt;a href="http://www.gnome.org"&gt;Gnome&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Just like GnuPG it also requires secure memory to get the best privacy;
I can never remember how to set this up, fortunately there's an &lt;a href="http://www.gnupg.org/faq.html#q6.1"&gt;faq on
gnupg.org&lt;/a&gt;so a quick...&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo chmod 4755 /usr/bin/seahorse*&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and we're done, no more error messages :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Tue, 22 Jan 2008 09:57:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2008-01-22:seahorse-is-running-in-insecure-memory</guid><category>gnome</category><category>gnupg</category><category>gpg</category><category>Linux</category><category>seahorse</category><category>Security</category></item></channel></rss>