Change Password via Powershell

Software-based VM-centric and flash-friendly VM storage + free version

Moderators: anton (staff), art (staff), Max (staff), Anatoly (staff)

Post Reply
janderson133
Posts: 9
Joined: Tue Apr 26, 2022 11:41 pm

Wed Apr 27, 2022 12:19 am

Hello,

I'm trying to change the password via powershell per this thread: https://forums.starwindsoftware.com/vie ... ord#p28708

The thread states the format of the password:
raw format: "##" + ToBase64(MD5(password))

original: "##evVRsIJtRmAEEd2sCslZDg==" from "starwind"
My understanding of MD5 is that it will always produce a 32 character string and so it can never be as short as what is referenced. My output is always much longer:

MD5 hash: 7af551b0826d46600411ddac0ac9590e
New server hash: ##NwBhAGYANQA1ADEAYgAwADgAMgA2AGQANAA2ADYAMAAwADQAMQAxAGQAZABhAGMAMABhAGMAOQA1ADkAMABlAA==

Code: Select all

    $password="starwind"
     $md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
     $utf8 = new-object -TypeName System.Text.UTF8Encoding
     $hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($password)))
     $hash = $hash.ToLower() -replace '-', ''
     write-host "MD5 hash: " $hash
     $StringBytes = [System.Text.Encoding]::Unicode.GetBytes($hash)
     # Encode string content to Base64 string
     $newpasswordhash = "##" + [Convert]::ToBase64String($StringBytes)
  
     write-host "New server hash: " $newpasswordhash
Thanks - Jeff
yaroslav (staff)
Staff
Posts: 2361
Joined: Mon Nov 18, 2019 11:11 am

Sat Apr 30, 2022 12:44 am

You have generated the MD5HASH value from starwind. Then, you have been using the hex value to generate the ToBase64 hash.
Try the following path Password string value -> md5 = 128 bit hash in hex format -> from hex value to base64 value.
janderson133
Posts: 9
Joined: Tue Apr 26, 2022 11:41 pm

Wed May 04, 2022 4:32 am

Thanks for the pointer and this code seems to work:

Code: Select all

$password="starwind"
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$utf8 = new-object -TypeName System.Text.UTF8Encoding
$hash = $md5.ComputeHash($utf8.GetBytes($password))
# Encode binary MD5 content to Base64 string
$newpasswordhash = "##" + [Convert]::ToBase64String($hash)

write-host "New server hash: " $newpasswordhash
yaroslav (staff)
Staff
Posts: 2361
Joined: Mon Nov 18, 2019 11:11 am

Wed May 04, 2022 1:33 pm

Good to know that it works. Please try typing the non-encrypted word to confirm it working.
Post Reply