Skip to content

A demo of rust RSA2 WASM for Wechat mini-program. 微信小程序 rsa2.

Notifications You must be signed in to change notification settings

lbb00/rust-rsa2-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RUST_RSA2_SIGN_WASM Demo

Usage

Install

brew install brotli
brew install llvm
export LLVM_PATH="your llvm path, like /usr/local/opt/llvm"

Build for wechat app

make build-wx-wasm

Example with Wechat Mini-Program

  • 将 pkg 下的 rsa2_sign.jsEncoderDecoderTogether.min.js 复制到小程序项目中的同一目录下.
  • 将 pkg 下的 rsa2_sign_bg.wasmrsa2_sign_bg.wasm.br 复制到小程序项目中。
import init, { rsa2_sign } from './rsa2_sign.js'

await init('wasm文件相对小程序项目的位置,如/utils/rsa2_sign_bg.wasm.br')
const res = rsa2_sign('okok')

Refs

  1. 找一个简单方便实用的 rsa 库 https://docs.rs/ring/latest/ring/
  2. ring 这个库 build --target web 会产生一段 import * as __wbg_star0 from 'env'; briansmith/ring#1483 (comment)
  3. 引入到小程序时需要注意的坑 https://juejin.cn/post/7041161141162082340#heading-6
  4. 小程序 ioscacheUnit8Memory0 和 wasm.memory.buffer 不能同步 https://developers.weixin.qq.com/community/develop/doc/000844fe3a43585c3c2e467795d000

About

A demo of rust RSA2 WASM for Wechat mini-program. 微信小程序 rsa2.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published