~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cloudconfig/windowsuserdatafiles/filesha256.ps1

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
Function Get-FileSHA256{
 
3
        Param(
 
4
                $FilePath
 
5
        )
 
6
        try {
 
7
                $hash = [Security.Cryptography.HashAlgorithm]::Create( "SHA256" )
 
8
                $stream = ([IO.StreamReader]$FilePath).BaseStream
 
9
                $res = -join ($hash.ComputeHash($stream) | ForEach { "{0:x2}" -f $_ })
 
10
                $stream.Close()
 
11
                return $res
 
12
        } catch [System.Management.Automation.RuntimeException] {
 
13
                return (Get-FileHash -Path $FilePath).Hash
 
14
        }
 
15
}