Linear encoding for strings.
import { encode } from 'np-encode';
let str = "Hi this is Obaid";
let enc_str = encode(str);
console.log(enc_str);
^78A+978+8A8+8A^+41083
$~
import { decode } from 'np-encode';
let enc_str = "^78A+978+8A8+8A^+41083";
let str = encode(enc_str);
console.log(str);
Hi this is Obaid
$~
This can be used with another type of encoding like base64 or some sort of ciphering algorithm:
import { encode } from 'np-encode';
let str = "Hi this is Obaid";
let enc_str = encode(str);
let double_enc_str = Buffer.from(enc_str,"utf-8").toString("base64");
console.log(double_enc_str);
Xjc4QSs5NzgrOEE4KzhBXis0MTA4Mw==
$~