.decrypt(password)
Description
decrypt uses AES decryption to decrypt a string that was encrypted using the .encrypt() method. The same password used for encryption must be provided.
Parameters
decrypt needs one parameter:
password: The password that was used for encryption
Usage On Strings
// Basic encryption and decryption
original = "secret message"
encrypted = original.encrypt("myPassword123")
decrypted = encrypted.decrypt("myPassword123")
log decrypted
// "secret message"
// Example with stored encrypted data
storedEncrypted = getSomeStoredEncryptedData()
decrypted = storedEncrypted.decrypt("secure-key")
// Returns original data if password matches
// Wrong password example
wrong = encrypted.decrypt("wrongPassword")
// Returns garbled text or fails
// Best practice: always verify decrypted data is valid
// before using it in your application
Last updated
Was this helpful?