open-index/open-npm huggingface dataset:
npm package: @fantai/enclib
Description: 用于ft-gateway请求数据的加密
Latest version: 0.2.6

# 前端加密库

用于ft-gateway请求数据的加密

安装
--------------

    npm install @fantai/enclib

api
--------------

m3b272a70(plainText: string): Promise<string> ft-gateway请求数据加密方法

base64(plainText: string): Promise<string> base64编码，用于ft-gateway请求的头信息编码

使用方式
--------------

1, node环境

    const ftenclib = require('@fantai/enclib');
    ftenclib.m3b272a70('test').then((result) => console.log(result));

2, 浏览器脚本方式

    <script src="@fantai/enclib/dist/ftenclib.js"></script>
    <script>
      console.log(String.fromCharCode(...ftenclib.m3b272a70('test')));
    </script>

3，vite环境打包

    import { base64, m3b272a70 } from '@fantai/enclib';
    ftenclib.m3b272a70('test').then((result) => console.log(result));

    // vite.config.js
    import { FantaiEnclibVitePlugin } from '@fantai/enclib/plugin.js';

    export default {
      optimizeDeps: {
        exclude: ['@fantai/enclib'],
      },
      plugins: [FantaiEnclibVitePlugin({ worker: true })],
    };

4, webpack环境打包

    import { m3b272a70, base64 } from '@fantai/enclib';

    m3b272a70('text').then((cipherText) => console.log(cipherText));
    base64('test').then((cipherText) => console.log(cipherText));

    // webpack.config.js
    import { FantaiEnclibWebpackPlugin } from '@fantai/enclib/plugin.js';

    export default {
      ...
      plugins: [new FantaiEnclibWebpackPlugin({ worker: true })],
    };

编译
------

编译typescript到wasm

    npm run asbuild:optimized

编译typescript到js (分别生成 esm 和 lib 两种模块格式)

    npm run tsbuild:esm && npm run tsbuild:lib

打包js和wasm文件

    npm run webpack

整体编译

    npm run build