New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@reverse/encoder

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reverse/encoder

Encodes values into a string.

latest
Source
npmnpm
Version
1.2.10
Version published
Maintainers
2
Created
Source

@reverse/encoder

Encodes values into a randomly generated string.

Generates random identifiers for input strings, the same input string will be the same output string (cached, not hashing). Used in some Reverse Squared projects for generating Error Codes that we can decode but outsiders without access will not be able to.

Install

npm install @reverse/encoder

Usage

Encoding Values

Use the encode() function to encode a value. It returns the code that you will have to decode.

import { encode } from '@reverse/encoder';

encode('Hello!');
// Example Output: "91887D"

If you encode the same value twice, the returned code will be the same as the first time you encoded that value.

Decoding Values

To decode the value, use the decode() function. It will return the original value that you encoded.

import { decode } from '@reverse/encoder';

// Assuming we use the same code in the above example.
decode('91887D');
// "Hello!"

Custom Identifier Generator

This module also exposes two functions for using the ID generator.

import { setIDGenerator } from '@reverse/encoder';

generateID(); // -> "123456" Example ID from default generator.

setIDGenerator(() => 'Hello'); // All generated IDs will be "Hello",
// this will crash the application after
// encoding two separate values.

generateID(); // -> "Hello"

Keywords

encoder

FAQs

Package last updated on 27 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts