.encrypt(password)
Description
encrypt uses AES encryption to securely encrypt a string with a password. The encrypted result can be decrypted using the same password with the .decrypt() method.
Parameters
encrypt needs one parameter:
password: The password to use for encryption
Usage On Strings
str = "secret message"
encrypted = str.encrypt("myPassword123")
// Returns AES encrypted string
// Can be decrypted with the same password
decrypted = encrypted.decrypt("myPassword123")
log decrypted
// "secret message"
// Different password won't decrypt correctly
wrong = encrypted.decrypt("wrongPassword")
// Returns garbled text or fails
// Useful for storing sensitive data
userInfo = "sensitive data"
stored = userInfo.encrypt("secure-key")
// Store the encrypted version
Last updated
Was this helpful?