0

I find that JSEncrypt encrypt.encrypt(password) with the same publicKey is different each time, such as: "G8PHyuxAsH3GcDPx3In7fpFVbu0o+APElFFjUJjtdn2mKZy+X1G8b3X3W+C5ANKNrtlPlx8cTPzCgpLKGfGy9g==""T0rPL4z48ZQ6Sve7Bljj/FAnSMZodiooYpB31S8oZOCaRFnKtDZ6UtvNv5xHL3hz/abW+2gybVpHWVDgEX5DYA==". But I can decrypt password correctly from them with privateKey.

jsencrypt.min.js

version: "3.0.0-rc.1"

function encryptPwd(password) {
    
    if (storeData.initData.publicKey) {
      var encrypt = new JSEncrypt();
      encrypt.setPublicKey(storeData.initData.publicKey);

      return encrypt.encrypt(password);
    } else {
      
      return encryptMd5(password);
    }
  }
Holinc
  • 641
  • 6
  • 17
  • 2
    Can you share exactly what you're using JSEncrypt for and a code example of how you're using it? Please update your question to show what you have already tried, showing the specific problem you are facing in a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve). For further information, please see [how to ask good questions](http://stackoverflow.com/help/how-to-ask), and take the [tour of the site](http://stackoverflow.com/tour). – coagmano Apr 12 '21 at 03:59
  • 1
    Password encryption tools (well, good ones) usually create a fairly large random "salt" value to prepend to the password for encryption. The salt is included as part of the encrypted password string, so it can be used when comparing a password candidate to the real passwords. **If you can decrypt passwords, you're using the wrong tool.** – Pointy Apr 12 '21 at 04:09

0 Answers0