in reply to How to encode/decode an SSHA256 hash?
I agree that it does not appear to be a valid SSHA256 hash but it would help if we knew the salt. Here's what I came up with after some searching.
#!/bin/env perl use strict; use warnings; use MIME::Base64; use Digest::SHA qw( sha256 ); # Only the first one can be validated... my @passwords = ( { encoded => 'M8Nbe/nfLJeVbV3XdvaLD44uxK77eAhJWEx1tIDLBCFteV +9zYWx0Xw==', password => 'P@ssw0rd!', salt => 'my_salt_', }, { encoded => 'B6HO7UNHVi5fglh1RpJXX4z1maGJ9lcicTVcy94ztsmzAe +kseg==', password => 'Passw0rd!', }, { encoded => 'KGOnPYya2qwhF9w4xK157EZZ/RqIxParohltZWU7h2T/VG +jNRA==', password => 'VMware1234!', } ); for my $pass ( @passwords ) { print "encoded: $pass->{encoded}\n"; my $decoded = MIME::Base64::decode_base64( $pass->{encoded} ); print "decoded: $decoded\n"; # Find digest and salt my @salt = unpack( 'C*', $decoded ); my @pass; push @pass, shift @salt for ( 1 .. 32 ); # shift the password off +leaving just the salt behind my $pw = pack( 'C32', @pass ); my $salt = pack( 'C*', @salt ); print "password digest: $pw\n"; print "salt: $salt\n"; print " salt matches what is stored\n" if ( defined $pass->{sa +lt} && $salt eq $pass->{salt} ); # Create a new password digest my $digest = sha256( $pass->{password} . $salt ); print "digest: $digest\n"; my $reencoded = MIME::Base64::encode_base64( $digest . $salt ); chomp $reencoded; print "reencoded (SSHA256): $reencoded\n"; print " reencoded matches the original encoded value!\n" if ( +$reencoded eq $pass->{encoded} ); print "\n\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to encode/decode an SSHA256 hash?
by FloydATC (Deacon) on Nov 20, 2014 at 11:16 UTC |