这篇文章主要以base64的数据到,blob的二进制对象和AES加密数据等的过程,然后进行AES(ECB、CBC)
1、从canvas中获取图片的base64数据

2、AES加、解密的方法
首先需要引入要用的module,即crypto-js(网上还有许多引用其他js的,也可参考,加解密方法几乎一样),可直接require或import引用,或者npm install crypto-js;然后引入,如下:

接着需要后端提供的key值和vi值(CBC需要用到),AES方法是支持AES-128、AES-192和AES-256的,加密过程中使用哪种加密方式取决于传入key的类型;这次支持的是AES-128,如下,示例的key值和vi值只是随便填写

a. ECB加密

b. ECB解密

c. CBC加密

d. CBC解密

3、转换成Blob的二进制对象

网友评论