Issue
I am installing Fedora Live Workstation on my laptop and I got stuck on the step "3.3.1. Verifying checksums on Windows systems" item "5.Calculate the downloaded image's checksum. This will take a while!". The Windows PowerShell keeps throwing the following exception:
$download_checksum = [System.BitConverter]::ToString($sha256.ComputeHash([System.IO.File]::ReadAllBytes("$PWD\$image"))).ToLower() -replace '-', '' Eccezione durante la chiamata di "ReadAllBytes" con "1" argomento/i: "Generata eccezione di tipo 'System.OutOfMemoryException'." (Exception during the call of "ReadAllBytes" with "1" argument:"Generate exception type 'System.OutOfMemoryException'.") In riga:1 car:104 (In line:1 char:104) + $download_checksum = [System.BitConverter]::ToString($sha256.ComputeHash([System.IO.File]::ReadAllBytes <<<< ("$PWD\$image"))).ToLower() -replace '-', '' + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
I am not proficient on Windows Powershell and not a very skilled programmer but in order to solve this problem I have raised some hypothesis. Please correct me if they're not relevant.
If the cause of this exception is the hardware (e.g. insufficient RAM memory to process the computation), are there any workarounds like splitting the computation into smaller steps allowing the computer to handle smaller chuncks of information?
Is it possible that the interpreter have gone overflow because of compilation mistakes while tweaking the instructions into the powershell?
Some important information might be:
- OS: Windows 7 Professional SP 1 Processor: Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz 2.40GHz
- RAM: 3,00GB (2,86GB Useful)
- OS Type: 64bit
- HD Available: 94,6 GB
Solution
Don't read the entire file into memory. Do this instead:
$filename = Join-Path $PWD $image
$sha256 = New-Object Security.Cryptography.SHA256CryptoServiceProvider
$stream = (Get-Item $filename).OpenRead()
$hash = $sha256.ComputeHash($stream)
$stream.Close()
$download_checksum = [BitConverter]::ToString($hash).ToLower() -replace '-'
Answered By - Ansgar Wiechers