# md5-node-cg-lib

> Library to create MD5 ids

Latest version **0.0.11** (published 2024-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install md5-node-cg-lib
pnpm add md5-node-cg-lib
yarn add md5-node-cg-lib
bun add md5-node-cg-lib
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2024-05-29 |
| First published | 2022-10-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jose Carlos Moreno Carbajal |
| Maintainers | cloudgenuser |
| Keywords | md5, n3xgen, cloudgen, library |

## Links

- npm: https://www.npmjs.com/package/md5-node-cg-lib
- Repository: https://github.com/CloudGenUser/md5-node-cg-lib
- Homepage: https://github.com/CloudGenUser/md5-node-cg-lib#readme
- Issues: https://github.com/CloudGenUser/md5-node-cg-lib/issues
- npm.io page: https://npm.io/package/md5-node-cg-lib

## Dependencies (1)

- [utils-nxg-cg](https://npm.io/package/utils-nxg-cg.md) git+https://npm:glpat-gcNPCAQysysMpnVUzhrR@git.cloudgen.cgdemos.com/n3xgen/efuse/connectors/libraries/utils-nxg-cg.git

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.0.11 (latest) — 2024-05-29
- 0.0.10 — 2022-11-14
- 0.0.9 — 2022-11-08
- 0.0.8 — 2022-11-08
- 0.0.7 — 2022-11-08
- 0.0.6 — 2022-11-08
- 0.0.5 — 2022-11-07
- 0.0.4 — 2022-11-07
- 0.0.3 — 2022-11-04
- 0.0.2 — 2022-11-04
- 0.0.1 — 2022-10-24

## README

[![N|Solid](https://cloudgensys.com/cg-demo/wp-content/uploads/2019/05/CG-Logo-01.png)](https://www.cloudgensys.com/)

# md5-node-cg-lib
## 1. Introduction

This library allows us to create an id md5 or, the creation of this md5 can with information in any encoding or any encoding and convert it to utf8, in the same way this library allows us to validate the integrity of the information by validating the id md5 with one new from the information that you want to validate

## 2. Library usage

The library can be installed from npm page with the next:
`npm install md5-node-cg-lib`, `npm i md5-node-cg-lib` or `yarn install md5-node-cg-lib`

### 2.1 Library Methods
#### Method getMd5ID
This method creates the md5 id, without validations, only create id with any parameter
  ##### Example:
  ```javascript
  const data = getMd5ID("Hello World");
  //Result will be id md5
  b10a8db164e0754105b7a99be72e3fe5
  ```

#### Method createSum
This method creates the md5 id with the method getMd5ID, but it validates data before send to the method getMd5ID, this method receives two arguments, first is the data to create id in any encoding, and the second parameter is flag, the flag is optional, the flag is value to the operation in components like sftp, ftp, ftps, and amazon aws, these components can create id, but only with the flag GETFILE, other flags are not valid.
  ##### Examples:
  ```javascript
  //Creating md5 id without flag
  console.log(createSum("ZWZyZnI="))
  console.log(createSum("ZWZyZnI"))
  //Result same md5 id
  361df7e337886f73e12e96dc186c78ec
  361df7e337886f73e12e96dc186c78ec
  
  //Example using flag
  console.log(JSON.stringify(createSum("ZWZyZnI", flags.CREATEDIRECTORY)))
  console.log(createSum("ZWZyZnI=", flags.GETFILE))
  //Result, if flag is not valid, the output will be a string empty
  ""
  361df7e337886f73e12e96dc186c78ec
  ```

#### Method checkSumMD5
This method check integrity of data, receives two arguments the first is msg and second is cfg, these parameters are received from the components, the validation is with property md5sum and content.
* If msg and cfg not contains property md5sum the result is true because we don’t have any to validate. 
* If msg or cfg contains md5sum but not contains property content, result will be false, because we need property content to validate integrity. 
* If msg or cfg contains both properties ‘md5sum’ and ‘content’, we can validate integrity the data creating md5id with property content with encoding utf8 and comparing this id with the id from the property md5sum, if both ids are the same the result will be can true, if not result will be can false. 

 ##### Example:
  ```javascript
  const data = {
    content: 'ZWZyZnI=',
    md5sum: '361df7e337886f73e12e96dc186c78ec'
  };

  console.log('Result is:', checkSumMD5({data}, {}));
  //The result is Boolean
  Result is: true
  ```

---
_Source: https://npm.io/package/md5-node-cg-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
