js-base64#toBase64 TypeScript Examples

The following examples show how to use js-base64#toBase64. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextEncryptTask.ts    From CocosCreator-Build-Encrypt with MIT License 6 votes vote down vote up
/**
     * 加密文本
     */
    private _encryptText(imgs: TextObject[]) {
        imgs.forEach((imgObj: TextObject) => {
            let buffer: Buffer = fs.readFileSync(imgObj.filePath);
            // 使用 node 自带的 base64
            // let encodeText: string = buffer.toString("base64");

            // 使用 js-base64 库,这是为了方便解密的时候,使用同样的库去解密
            let encodeText = toBase64(buffer.toString());
            encodeText += RandomUtil.randomString(10);
            fs.writeFileSync(imgObj.filePath, encodeText);
        });
    }