What is Jasypt encryption?
Jasypt, Java Simplified Encryption, is a library that encrypts values with a password. Its best-known use is in Spring Boot: you write a database password or API key in application.properties as ENC(...), and the application decrypts it at startup with a password you supply from the environment. The file can then go into Git without the secret in clear text.
This page encrypts and decrypts strings in the Jasypt format, in your browser. It supports the PBEWithHMACSHA512AndAES_256 algorithm, which is the default of jasypt-spring-boot 3, and the other HMAC variants with AES-256 or AES-128, plus the legacy PBEWithMD5AndTripleDES and PBEWithMD5AndDES. It was checked against real Jasypt 1.9.3 output, so a value made here decrypts in Java and the other way around.
The encrypted text is Base64 of three parts: the random salt, then the initialization vector for the AES algorithms, then the encrypted bytes. The password goes through the chosen number of key iterations to make the key. Every encryption uses a new random salt, so the same text gives a different value each time, and all of them decrypt to the same text.
Be clear about what this protects. It keeps a secret out of a repository and out of casual view. It does not make the secret safe if the decryption password sits next to the file, or if an attacker can read the environment of the running application. Prefer the strong algorithm. The MD5 with DES one is old and weak, and the page marks it "old, study only": it is there to read values from old applications.
Everything runs locally, and neither the password nor the text is sent anywhere.
How to encrypt and decrypt
- Choose What to do: Encrypt or Decrypt.
- To encrypt, type the Text to encrypt:. To decrypt, paste the Encrypted text (with or without ENC(...)):.
- Type the Encryption password:.
- Pick the Algorithm: and the Key iterations:. They must be the same you will configure in the application. The default of 1000 iterations matches jasypt-spring-boot.
- Read the Result. When encrypting you get For application.properties or application.yml: with the
ENC(...)wrapper, and Encrypted value alone:. Use Copy text. - Press Encrypt again for another value, or Decrypt this to check it to confirm that it comes back.
- In Spring Boot, set
jasypt.encryptor.password,jasypt.encryptor.algorithmandjasypt.encryptor.iterationsto what you used here.
Examples
A value for application.properties
Encrypt a database URL with the default algorithm, and put the wrapped result in your file:
spring.datasource.password=ENC(...)Supply the password at runtime, for example as the JASYPT_ENCRYPTOR_PASSWORD environment variable, never in the same repository.
Reading a value from an old application
This value is from real Jasypt, made with the password my secret pw, PBEWithMD5AndDES and 1000 iterations:
3qTtXCv8Ny/q9lgW53rNm3JYGE9njb/vDecrypt it with those settings and you get hello world. It decodes to 24 bytes: 8 of salt and 16 of encrypted data. Decrypt with a different algorithm or iteration count and you get an error, not garbage.
Two encryptions of the same text
Encrypt hello twice with the same password. The two values differ because the salt is random, and both decrypt to hello. Do not compare encrypted values to see if two secrets are equal.
Moving to a stronger algorithm
To retire a legacy value, decrypt it with the old algorithm, then choose PBEWithHMACSHA512AndAES_256 and encrypt the text again. Update the application settings at the same time.
Common mistakes
- "Type the encryption password." The password is required.
- "Iterations must be a whole number from 1 to 10000000."
- "The text is not Base64. Paste only the encrypted value, or ENC(...) around it." Remove quotes, spaces or a
key=prefix. - "The encrypted value is too short for this algorithm (it needs more than N bytes). Check the algorithm." AES values need more bytes than the DES ones, so the algorithm is probably wrong.
- "Could not decrypt. The password, the algorithm or the iterations are not the ones used to encrypt." The most common one. Check all three.
- Different defaults. Jasypt 1.x defaulted to PBEWithMD5AndDES; jasypt-spring-boot 3 uses PBEWITHHMACSHA512ANDAES_256. A value from an old project may need the old algorithm.
Frequently asked questions
Is Jasypt a replacement for a secrets manager?
No. It is a way to keep values out of plain text in a file. A secrets manager gives you rotation, access control and an audit trail. For pipelines, see also Ansible Vault, which does a similar job for Ansible files.
Why does the same text give a different result each time?
Each encryption adds a random salt. It protects against precomputed attacks and means two equal secrets do not look equal.
Which password should I use?
A long random one. To judge it, use the password strength analyser, and to make one, the token generator.
Does the page store my password?
No. It is only in the page while you type, and is not written to the address or to storage.
Equivalent settings
# application.properties
jasypt.encryptor.algorithm=PBEWITHHMACSHA512ANDAES_256
jasypt.encryptor.iterations=1000
jasypt.encryptor.password=${JASYPT_PASSWORD}# Run with the password from the environment
JASYPT_PASSWORD='my secret pw' java -jar app.jar