# StringEx

### Imports

{% tabs %}
{% tab title="Service" %}

```typescript
import { StringExService } from 'niro-health';
```

{% endtab %}

{% tab title="Module" %}

```typescript
import { StringExModule } from 'niro-health';
```

{% endtab %}

{% tab title="Interface" %}

```typescript
import type { IStringExService } from 'niro-health';
```

{% endtab %}
{% endtabs %}

### Method of Use

To use this module, you need to inject it into the desired service.

{% code overflow="wrap" %}

```typescript
import { Module } from '@nestjs/common';
import {
  StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}
```

{% endcode %}

Injecting the module into our service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IStringExService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IStringExService')
    private readonly stringExService: IStringExService,
  ) {}

  public async hashPassword(password: string) {
    return await this.stringExService.hashPassword(password);
  }
}
```

### Without dependencies

You won't need to connect the pieces with any other module.

### Methods

<table><thead><tr><th width="269.3333333333333">Method</th><th width="102" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>LZStringCompressToEncodedURIComponent</code></td><td align="center"><code>public</code></td><td><code>Compresses a string to EncodedURIComponent.</code></td></tr><tr><td><code>LZStringDecompressFromEncodedURIComponent</code></td><td align="center"><code>public</code></td><td><code>Decompresses a string from EncodedURIComponent to string.</code></td></tr><tr><td><code>compress</code></td><td align="center"><code>public</code></td><td><code>Compresses a {string | Uint8Array | Buffer} to base64.</code></td></tr><tr><td><code>decompress</code></td><td align="center"><code>public</code></td><td><code>Decompresses a string from base64 to {Type | string | Uint8Array | Buffer}.</code></td></tr><tr><td><code>hashPassword</code></td><td align="center"><code>public</code></td><td><code>Return hash from password.</code></td></tr><tr><td><code>compareHashPassword</code></td><td align="center"><code>public</code></td><td><code>Compare hash from password.</code></td></tr><tr><td><code>hash</code></td><td align="center"><code>public</code></td><td><code>Return hash from string.</code></td></tr><tr><td><code>bytesToString</code></td><td align="center"><code>public</code></td><td><code>Return bytes to string.</code></td></tr><tr><td><code>getFilename</code></td><td align="center"><code>public</code></td><td><code>Get name of file.</code></td></tr><tr><td><code>getFileExtension</code></td><td align="center"><code>public</code></td><td><code>Get extension of file.</code></td></tr><tr><td><code>extractNumbers</code></td><td align="center"><code>public</code></td><td><code>Extract numbers from string.</code></td></tr><tr><td><code>maskMoney</code></td><td align="center"><code>public</code></td><td><code>Convert a string to money format.</code></td></tr><tr><td><code>maskPhone</code></td><td align="center"><code>public</code></td><td><code>Convert a string to phone pretty.</code></td></tr><tr><td><code>maskZipCode</code></td><td align="center"><code>public</code></td><td><code>Convert a string to zip code pretty.</code></td></tr><tr><td><code>maskCNPJ</code></td><td align="center"><code>public</code></td><td><code>Convert a string to CNPJ pretty.</code></td></tr><tr><td><code>maskCPF</code></td><td align="center"><code>public</code></td><td><code>Convert a string to CPF pretty.</code></td></tr><tr><td><code>maskRG</code></td><td align="center"><code>public</code></td><td><code>Convert a string to RG pretty.</code></td></tr></tbody></table>


---

# 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://guilhermesantos.gitbook.io/niro-health/modules/stringex.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.
