# MosCrypto

The MosCrypto object provides access to some cryptographic functions.

### Methods <a href="#h.2av81iyk042f" id="h.2av81iyk042f"></a>

| **Name**                              | **Description**                                                             |
| ------------------------------------- | --------------------------------------------------------------------------- |
| toBase64(byteArray)                   | Converts input byte array into output byte array in Base64 format.          |
| fromBase64(byteArray)                 | Converts input byte array in Base64 format into source byte array.          |
| toBase64String(byteArray)             | Converts input byte array into Base64 string.                               |
| getSha1Hash(byteArray)                | Returns SHA1 hash for input byte array as byte array.                       |
| getSha256Hash(byteArray)              | Returns SHA256 hash for input byte array as byte array.                     |
| getSha384Hash(byteArray)              | Returns SHA384 hash for input byte array as byte array.                     |
| getSha512Hash(byteArray)              | Returns SHA512 hash for input byte array as byte array.                     |
| getMd5Hash(byteArray)                 | Returns MD5 hash for input byte array as byte array.                        |
| bytesToHex(byteArray)                 | Converts input byte array into HEX string.                                  |
| getGuidAsBytes()                      | Generates GUID as byte array.                                               |
| getGuidAsString()                     | Generates GUID as string formatted as XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. |
| <p>encodeUri(keys, values)</p><p></p> | Encodes (key/value) pairs for URI.                                          |

The following example shows a script that converts the source string to a Base64 string:

```javascript
var input = 'input string';
var bytes = MosText.utf8ToBytes(input);
var base64 = MosCrypto.toBase64String(bytes);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.monokot.io/scripts/api/moscrypto.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
