0

I have java code that use jasypt (Java Simplified Encryption) library:

    StandardStringDigester digester = new StandardStringDigester();
    digester.setAlgorithm("MD5");
    digester.setIterations(1);

    FixedStringSaltGenerator saltGenerator = new FixedStringSaltGenerator();
    saltGenerator.setSalt("justAnotherSalt");

    digester.setSaltGenerator(saltGenerator);
    digester.setSaltSizeBytes(5);

    String digest = digester.digest("my_password");

    System.out.println(digest);

You can see that I used MD5 algorithm with salt.

The result in console is:

I9uMOxDiImtxMXKXkt2EUw==

I want to know why there are "==" characters in the end of result string? It's only exist if I used Salt.

null
  • 8,669
  • 16
  • 68
  • 98
  • 2
    See related: http://stackoverflow.com/questions/6916805/why-base64-encoding-string-have-sign-in-the-last – Krease Mar 21 '13 at 05:56

1 Answers1

3

StandardStringDigester.digest API says The result is encoded in BASE64 (default) or HEXADECIMAL and returned as an ASCII String. In your case this is BASE64

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
  • It's said that in wikipedia: The '==' sequence indicates that the last group contained only 1 byte. What does it mean by the last group? – null Mar 21 '13 at 06:07
  • 1
    base64 converts each group of 3 bytes -> 4 chars. If the last group is 2 bytes the result is padded with '='. If it is 1 byte the result is padded with "==". – Evgeniy Dorofeev Mar 21 '13 at 06:24