Expand my Community achievements bar.

Problem with computeDigest of SHA256

Avatar

Level 2

Hello,

       The following is  my actionscript code to compute digest for old and new password whenever you change password.

var newBytes:ByteArray = new

ByteArray();

var oldBytes:ByteArray = new

ByteArray();

saveAccount.request.username = userName;

oldBytes.writeUTFBytes(

"aaaa"

);

var

len:int = oldBytes.length;

var temp:String = oldBytes.toString();

//SHA256.computeDigest(oldBytes);

saveAccount.request.oldpassword = SHA256.computeDigest(oldBytes);

newBytes.writeUTFBytes(

"qqqq"

);

len = newBytes.length;

temp = newBytes.toString();

//SHA256.computeDigest(newBytes);

saveAccount.request.newpassword = SHA256.computeDigest(newBytes);

saveAccount.send();

I hard coded the old password and new password to make sure what i get after compute digest.. but surprisingly both compute digest of both oldBytes and newBytes give the same digest.."df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119" . Only when the number of characters in the old and new password are different then the digest differs?.. is this right?

Thanks,

Bharani

1 Reply

Avatar

Level 1

Hi

I have the same problem : SHA256.computeDigest returns equal digests for not equal strings with the same length.

Do you have you another approach for calculating digest ?

Thanks