Can two different BASE64 encoded strings result into same string if decoded?

后端 未结 2 950
刺人心
刺人心 2021-02-10 01:33

On client side I am doing an MD5 encryption of a string and then a BASE 64 encoding on the hash generated.

This final encoded string is then used for comparison on serve

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-10 02:09

    You have the MD5 Hash 291423A531148527A9524EA0924CDF68 that generates the Base64 encoded string MjkxNDIzQTUzMTE0ODUyN0E5NTI0RUEwOTI0Q0RGNjg= , which is fine. You have converted the MD5 hash to an ascii hex representation, and base64 encoded that.

    However your own getHashCode() works differently, it creates a base64 encoding of the binary representation of your hash code, you have not converted your hash to an ascii hex representation, and that's why you see different base64 encoded strings.

提交回复
热议问题