> For the complete documentation index, see [llms.txt](https://osl.mistium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osl.mistium.com/legacy-osl-originos/prototype-helpers/.encrypt.md).

# string.encrypt

## 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

```javascript
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
```
