Solved Powershell command to generate SHA512 Base64 checksum


Sephirote

Well-known member
Member
Local time
12:41 AM
Posts
70
OS
Windows 11
Hi everyone,

Does anyone know the command to generate a SHA512 checksum with Base64 encoding?
Just to clarify, the standard encoding for SHA512 is HEX but the checksum I'm trying to verify was generated Base64 encoding.

Here's the command I'm using to generate the standard SHA512 HEX.

Get-FileHash -Path C:\Users\XXX\Downloads\FILENAME -Algorithm SHA512

But I don't know the command to generate SHA512 Base64.

No need to suggest installing a software, I'm aware of those, I prefer to use a command.

Thanks
 

My Computer My Computer

At a glance

Windows 1111th Gen Intel(R) Core(TM) i7-11800H32GBNvidia Gefore RTX 3050 Ti
OS
Windows 11
Computer type
Laptop
CPU
11th Gen Intel(R) Core(TM) i7-11800H
Memory
32GB
Graphics Card(s)
Nvidia Gefore RTX 3050 Ti
Monitor(s) Displays
OLED

My Computer My Computer

At a glance

Windows 11, Windows 10, Linux Fedora Cinnamon
OS
Windows 11, Windows 10, Linux Fedora Cinnamon
I can't testify to it's accuracy but this according to AI. Co-pilot says:
One possible PowerShell command to generate SHA512 Base64 checksum for a file is:

# Get the hash of the file
$hash = Get-FileHash <path to input file> -Algorithm SHA512
# Convert hash to byte representation
$hashBytes = [System.Text.Encoding]::Unicode.GetBytes ($hash.Hash)
# Convert bytes to base64, then output to file
[System.Convert]::ToBase64String ($hashBytes) | Out-File <path to hash output file>

This command is based on the answer from Stack Overflow1. You can also use other hash algorithms that are supported by PowerShell, such as MD5, SHA1, SHA256, or SHA384. For more information, you can refer to the official documentation of the Get-FileHash cmdlet2. Alternatively, you can use the certutil.exe tool to generate and verify checksums in Windows34.
 

My Computers My Computers

  • At a glance

    Windows 11 Pro 25H2 26200.8655i9-10900 10 core 20 threads32 gbnone-Intel UHD Graphics 630
    OS
    Windows 11 Pro 25H2 26200.8655
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Optiplex 7080
    CPU
    i9-10900 10 core 20 threads
    Motherboard
    DELL 0J37VM
    Memory
    32 gb
    Graphics Card(s)
    none-Intel UHD Graphics 630
    Sound Card
    Integrated Realtek
    Monitor(s) Displays
    Benq 27
    Screen Resolution
    2560x1440
    Hard Drives
    2x1tb Solidigm m.2 nvme /External drives 512gb Samsung m.2 sata+2tb Kingston m2.nvme
    PSU
    500w
    Case
    MT
    Cooling
    Dell Premium
    Keyboard
    Logitech wired
    Mouse
    Logitech wireless
    Internet Speed
    so slow I'm too embarrassed to tell
    Browser
    #1 Edge #2 Firefox
    Antivirus
    Defender+MWB Premium
  • At a glance

    Windows 11 Pro 24H2 26200.8457AMD Ryzen 7 6800U32 gbintegrated
    Operating System
    Windows 11 Pro 24H2 26200.8457
    Computer type
    PC/Desktop
    Manufacturer/Model
    Beelink Mini PC SER5
    CPU
    AMD Ryzen 7 6800U
    Memory
    32 gb
    Graphics card(s)
    integrated
    Sound Card
    integrated
    Monitor(s) Displays
    Benq 27
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Crucial nvme
    Keyboard
    Logitech wired
    Mouse
    Logitech wireless
    Internet Speed
    still too embarrassed to tell
    Browser
    Firefox
    Antivirus
    Defender
    Other Info
    System 3 is non compliant Dell 9020 i7-4770/24gb ram Win11 PRO 26200.8457
You can use the attached batch script to add Hash to context menu of files in Windows 8, Windows 10 and Windows 11.
 

Attachments

My Computer My Computer

At a glance

Windows 11AMD Ryzen 7 5700GMicron Technology DDR4-3200 16GBNVIDIA GeForce RTX 3060
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
HP Pavilion
CPU
AMD Ryzen 7 5700G
Motherboard
Erica6
Memory
Micron Technology DDR4-3200 16GB
Graphics Card(s)
NVIDIA GeForce RTX 3060
Sound Card
Realtek ALC671
Monitor(s) Displays
Samsung SyncMaster U28E590
Screen Resolution
3840 x 2160
Hard Drives
SAMSUNG MZVLQ1T0HALB-000H1
I can't testify to it's accuracy but this according to AI. Co-pilot says:
One possible PowerShell command to generate SHA512 Base64 checksum for a file is:

# Get the hash of the file
$hash = Get-FileHash <path to input file> -Algorithm SHA512
# Convert hash to byte representation
$hashBytes = [System.Text.Encoding]::Unicode.GetBytes ($hash.Hash)
# Convert bytes to base64, then output to file
[System.Convert]::ToBase64String ($hashBytes) | Out-File <path to hash output file>

This command is based on the answer from Stack Overflow1. You can also use other hash algorithms that are supported by PowerShell, such as MD5, SHA1, SHA256, or SHA384. For more information, you can refer to the official documentation of the Get-FileHash cmdlet2. Alternatively, you can use the certutil.exe tool to generate and verify checksums in Windows34.
Thanks for the input.

So I got the Hash of the file using
Get-FileHash <path to input file> -Algorithm SHA512
29DA971D3A045CFB1243036BE2158967E22102689B87AAFB0C24A9B8EFC396DA6A88A0318312A24511CF41129AD3BA3FF125A3C75AB84B3FA058C078D01D7797

Then converted to byte representation
1703412501528.png

50
57
68
65
57
55
49
68
51
65
48
52
53
67
70
66
49
50
52
51
48
51
54
66
69
50
49
53
56
57
54
55
69
50
50
49
48
50
54
56
57
66
56
55
65
65
70
66
48
67
50
52
65
57
66
56
69
70
67
51
57
54
68
65
54
65
56
56
65
48
51
49
56
51
49
50
65
50
52
53
49
49
67
70
52
49
49
50
57
65
68
51
66
65
51
70
70
49
50
53
65
51
67
55
53
65
66
56
52
66
51
70
65
48
53
56
67
48
55
56
68
48
49
68
55
55
57
55

Then converted byte representation to base64

1703412636293.png

MjlEQTk3MUQzQTA0NUNGQjEyNDMwMzZCRTIxNTg5NjdFMjIxMDI2ODlCODdBQUZCMEMyNEE5QjhFRkMzOTZEQTZBODhBMDMxODMxMkEyNDUxMUNGNDExMjlBRDNCQTNGRjEyNUEzQzc1QUI4NEIzRkEwNThDMDc4RDAxRDc3OTc=

And the base64 hash I get is different than what it should be (downloaded file from the internet)

Unsure if it's an error on my end or if the downloaded file is compromised. Most likely an error on my end.

I would appreciate if someone with a few min to spare could run the command on their end just to see if they end up with the same base64

The SHA512 hash (step 1) should be correct as I also used an online SHA512 checksum tool to double-check and it gave me the same hash as the one I got via powershell

If I made a mistake, it would have occurred when converting to byte representation and then back to base64.
 

My Computer My Computer

At a glance

Windows 1111th Gen Intel(R) Core(TM) i7-11800H32GBNvidia Gefore RTX 3050 Ti
OS
Windows 11
Computer type
Laptop
CPU
11th Gen Intel(R) Core(TM) i7-11800H
Memory
32GB
Graphics Card(s)
Nvidia Gefore RTX 3050 Ti
Monitor(s) Displays
OLED
It's because you're encoding the hash as ASCII and then converting that encoded hash to Base64. You should just be able to provide hash directly to ToBase64String.
 

My Computer My Computer

At a glance

Windows 11, Windows 10, Linux Fedora Cinnamon
OS
Windows 11, Windows 10, Linux Fedora Cinnamon

My Computer My Computer

At a glance

Windows 11 Pro 23H2Intel i3 8100 @3.6Ghz1 x 16GB DDR4 @2400 MHzNvidia GeForce GT 1030 2GB SDDR4
OS
Windows 11 Pro 23H2
Computer type
PC/Desktop
Manufacturer/Model
MSI / MS-7B29
CPU
Intel i3 8100 @3.6Ghz
Motherboard
H310M PRO-VDH (MS-7B29)
Memory
1 x 16GB DDR4 @2400 MHz
Graphics Card(s)
Nvidia GeForce GT 1030 2GB SDDR4
Sound Card
Realtek VEN_10EC&DEV_0887 / NVIDIA VEN_10DE&DEV_0081
Monitor(s) Displays
Acer V226HQL
Screen Resolution
1920 x 1080
Hard Drives
SSD 500 GB Crucial MX500 / HDD 1 TB TOSHIBA DT01ACA100
PSU
ATX, details unknown
Case
Everest 551B
Cooling
details unknown
Keyboard
Mechanical Gaming Hydra R7 - Rampage
Mouse
Logitech G703
Internet Speed
Down: 28Mbps / Up: 19Mbps
Browser
Microsoft Edge
Antivirus
Microsoft Defender Antivirus
Other Info
Bluetooth: TP Link 5.0 Nano USB adapter UB500
WLAN: D-Link 150 Pico USB adapter, N standard
Web camera: Logitech C270 HD 720p @30fps
Microphone: Trust MICO, model 23790
Ok thanks

Hash512 >UTF8 bytes >Base64
1703416325118.png

Interestingly enough the final hash was really close to the provided base64 hash but not a match

Hash512 >Unicode bytes >Base64
1703416471335.png

Not a match

The other option suggested is to provide directly the SHA512 hash to ToBase64String but I'm not sure how to do that
 

My Computer My Computer

At a glance

Windows 1111th Gen Intel(R) Core(TM) i7-11800H32GBNvidia Gefore RTX 3050 Ti
OS
Windows 11
Computer type
Laptop
CPU
11th Gen Intel(R) Core(TM) i7-11800H
Memory
32GB
Graphics Card(s)
Nvidia Gefore RTX 3050 Ti
Monitor(s) Displays
OLED
@Sephirote
Why don't you just follow the example from SO?

Your screenshot shows you're computing hash value of another hash value rather than hash value of the data.
 

My Computer My Computer

At a glance

Windows 11 Pro 23H2Intel i3 8100 @3.6Ghz1 x 16GB DDR4 @2400 MHzNvidia GeForce GT 1030 2GB SDDR4
OS
Windows 11 Pro 23H2
Computer type
PC/Desktop
Manufacturer/Model
MSI / MS-7B29
CPU
Intel i3 8100 @3.6Ghz
Motherboard
H310M PRO-VDH (MS-7B29)
Memory
1 x 16GB DDR4 @2400 MHz
Graphics Card(s)
Nvidia GeForce GT 1030 2GB SDDR4
Sound Card
Realtek VEN_10EC&DEV_0887 / NVIDIA VEN_10DE&DEV_0081
Monitor(s) Displays
Acer V226HQL
Screen Resolution
1920 x 1080
Hard Drives
SSD 500 GB Crucial MX500 / HDD 1 TB TOSHIBA DT01ACA100
PSU
ATX, details unknown
Case
Everest 551B
Cooling
details unknown
Keyboard
Mechanical Gaming Hydra R7 - Rampage
Mouse
Logitech G703
Internet Speed
Down: 28Mbps / Up: 19Mbps
Browser
Microsoft Edge
Antivirus
Microsoft Defender Antivirus
Other Info
Bluetooth: TP Link 5.0 Nano USB adapter UB500
WLAN: D-Link 150 Pico USB adapter, N standard
Web camera: Logitech C270 HD 720p @30fps
Microphone: Trust MICO, model 23790
@Sephirote
Why don't you just follow the example from SO?

Your screenshot shows you're computing hash value of another hash value rather than hash value of the data.
Sorry but the answers provided aren't really clear/helpful. The issue with you guys is that you assume that you're talking to programmers and skip on the small details/steps that may be obvious to you but not to regular people. I'm not familiar with what Unicode or ASCII is, I try to figure it out as I go with Google but if I'm here asking for help, it didn't cross your mind that I may not be fluent in coding, powershell commands and other hash algorithms. I provided the SHA512, wouldn't have been possible to provide me with the commands instead of unhelpful comments instructing me not to use ASCII but Unicode which I have no clue how to do. I mean you have seen the screenshots, I'm trying to be proactive and to find the solution by myself not just waiting to have the solution mouth fed so give me a break with your silly questions like "why don't you do this or that" Because I don't know how to man.

Never mind I found this site where you input the HEX string and it spits out the base64.

Here's the website for anyone who comes across this thread looking for the same thing, because you sure won't find the solutions in the answers I received

Cheers
 

My Computer My Computer

At a glance

Windows 1111th Gen Intel(R) Core(TM) i7-11800H32GBNvidia Gefore RTX 3050 Ti
OS
Windows 11
Computer type
Laptop
CPU
11th Gen Intel(R) Core(TM) i7-11800H
Memory
32GB
Graphics Card(s)
Nvidia Gefore RTX 3050 Ti
Monitor(s) Displays
OLED
@Sephirote
Sorry, maybe you missed it but @glasskuter gave you link to SO (in post #3) which has the example, here is the link:

Does following the example work?

You so far have been doing all just not as shown in the example, that why I said why don't you follow the example from SO.
 

My Computer My Computer

At a glance

Windows 11 Pro 23H2Intel i3 8100 @3.6Ghz1 x 16GB DDR4 @2400 MHzNvidia GeForce GT 1030 2GB SDDR4
OS
Windows 11 Pro 23H2
Computer type
PC/Desktop
Manufacturer/Model
MSI / MS-7B29
CPU
Intel i3 8100 @3.6Ghz
Motherboard
H310M PRO-VDH (MS-7B29)
Memory
1 x 16GB DDR4 @2400 MHz
Graphics Card(s)
Nvidia GeForce GT 1030 2GB SDDR4
Sound Card
Realtek VEN_10EC&DEV_0887 / NVIDIA VEN_10DE&DEV_0081
Monitor(s) Displays
Acer V226HQL
Screen Resolution
1920 x 1080
Hard Drives
SSD 500 GB Crucial MX500 / HDD 1 TB TOSHIBA DT01ACA100
PSU
ATX, details unknown
Case
Everest 551B
Cooling
details unknown
Keyboard
Mechanical Gaming Hydra R7 - Rampage
Mouse
Logitech G703
Internet Speed
Down: 28Mbps / Up: 19Mbps
Browser
Microsoft Edge
Antivirus
Microsoft Defender Antivirus
Other Info
Bluetooth: TP Link 5.0 Nano USB adapter UB500
WLAN: D-Link 150 Pico USB adapter, N standard
Web camera: Logitech C270 HD 720p @30fps
Microphone: Trust MICO, model 23790
Could you please provide an example file (link to a small file) that uses base64 encoding for it's hashes so I can download and verify my results in PS?

Nevermind
 
Last edited:

My Computers My Computers

  • At a glance

    Win 11 Pro 25H2 26200.8457 / Linux Mint 22.3Ryzen 7 2700U Pro32GBiGPU Vega 10
    OS
    Win 11 Pro 25H2 26200.8457 / Linux Mint 22.3
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo A485
    CPU
    Ryzen 7 2700U Pro
    Motherboard
    Lenovo (WiFi/BT module upgraded to Intel Wireless-AC-9260)
    Memory
    32GB
    Graphics Card(s)
    iGPU Vega 10
    Sound Card
    Realtek
    Monitor(s) Displays
    14" FHD (built-in) + 14" Lenovo Thinkvision M14t (touch+pen) + 32" Asus PB328
    Screen Resolution
    FHD + FHD + 1440p
    Hard Drives
    Intel 660p m.2 nVME PCIe3.0 x2 512GB
    PSU
    125W(Dock)/65W(Travel Adapter)
    Keyboard
    Thinkpad / Logitech MX Keys
    Mouse
    Logitech MX Master 2S
    Internet Speed
    1/1Gbit
    Browser
    Firefox
    Antivirus
    Windows Defender
    Other Info
    SecureBoot: Enabled
    TPM2.0: Enabled
    AMD-V: Enabled
  • At a glance

    Win 11 Pro 25H2 26200.8521(RP)i7-7700k @4.8GHz32GB 2x16GB 2133MHz CL15EVGA GTX1080Ti FTW 11GB
    Operating System
    Win 11 Pro 25H2 26200.8521(RP)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom
    CPU
    i7-7700k @4.8GHz
    Motherboard
    Asus PRIME Z270-A
    Memory
    32GB 2x16GB 2133MHz CL15
    Graphics card(s)
    EVGA GTX1080Ti FTW 11GB
    Sound Card
    Integrated
    Monitor(s) Displays
    32" 10-bit Asus PB328Q
    Screen Resolution
    WQHD 2560x1440
    Hard Drives
    512GB ADATA SX8000NP NVMe PCIe Gen 3 x4
    PSU
    850W
    Case
    Fractal Design Define 7
    Cooling
    Noctua NH-D15 chromax.black
    Keyboard
    Logitech MX Keys
    Mouse
    Logitech MX Master 2S
    Internet Speed
    1/1Gbit
    Browser
    Firefox
    Antivirus
    Windows Defender
    Other Info
    AC WiFi Card
Here is the full solution that should work:

Powershell:
# Getting the HEX-String for SHA512
$HexString = Get-FileHash [Path To Your FILE] -Algorithm SHA512

# Printing out the HEX-String (Using .Hash here because HexString is an object with a lot of data)
$HexString.Hash

# Converting HEX-String to Bytes (as of SO solution provided, but with a small fix)
$bytes = [byte[]] -split ($HexString.Hash -replace '..', '0x$& ')

# Converting the resulting bytes into Base64 encoding and spitting out the result
[System.Convert]::ToBase64String($bytes)

Result:

Code:
582EBD465253994DC564D55F7C4AAD3D7679981A4623DA163F87F7B588E456D76400B79D0741F48B33211347DF05BA5D9900E841DF643CA8D1B2A3582631CC06
WC69RlJTmU3FZNVffEqtPXZ5mBpGI9oWP4f3tYjkVtdkALedB0H0izMhE0ffBbpdmQDoQd9kPKjRsqNYJjHMBg==
 

My Computers My Computers

  • At a glance

    Win 11 Pro 25H2 26200.8457 / Linux Mint 22.3Ryzen 7 2700U Pro32GBiGPU Vega 10
    OS
    Win 11 Pro 25H2 26200.8457 / Linux Mint 22.3
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo A485
    CPU
    Ryzen 7 2700U Pro
    Motherboard
    Lenovo (WiFi/BT module upgraded to Intel Wireless-AC-9260)
    Memory
    32GB
    Graphics Card(s)
    iGPU Vega 10
    Sound Card
    Realtek
    Monitor(s) Displays
    14" FHD (built-in) + 14" Lenovo Thinkvision M14t (touch+pen) + 32" Asus PB328
    Screen Resolution
    FHD + FHD + 1440p
    Hard Drives
    Intel 660p m.2 nVME PCIe3.0 x2 512GB
    PSU
    125W(Dock)/65W(Travel Adapter)
    Keyboard
    Thinkpad / Logitech MX Keys
    Mouse
    Logitech MX Master 2S
    Internet Speed
    1/1Gbit
    Browser
    Firefox
    Antivirus
    Windows Defender
    Other Info
    SecureBoot: Enabled
    TPM2.0: Enabled
    AMD-V: Enabled
  • At a glance

    Win 11 Pro 25H2 26200.8521(RP)i7-7700k @4.8GHz32GB 2x16GB 2133MHz CL15EVGA GTX1080Ti FTW 11GB
    Operating System
    Win 11 Pro 25H2 26200.8521(RP)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom
    CPU
    i7-7700k @4.8GHz
    Motherboard
    Asus PRIME Z270-A
    Memory
    32GB 2x16GB 2133MHz CL15
    Graphics card(s)
    EVGA GTX1080Ti FTW 11GB
    Sound Card
    Integrated
    Monitor(s) Displays
    32" 10-bit Asus PB328Q
    Screen Resolution
    WQHD 2560x1440
    Hard Drives
    512GB ADATA SX8000NP NVMe PCIe Gen 3 x4
    PSU
    850W
    Case
    Fractal Design Define 7
    Cooling
    Noctua NH-D15 chromax.black
    Keyboard
    Logitech MX Keys
    Mouse
    Logitech MX Master 2S
    Internet Speed
    1/1Gbit
    Browser
    Firefox
    Antivirus
    Windows Defender
    Other Info
    AC WiFi Card

Latest Support Threads

Back
Top Bottom