You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{encode}from'@clownlee/utils';consthtml='<div><h1>哈哈哈哈</h1><h2>嘿嘿嘿嘿</h2></div>'consttext=encode(html)// text = <div><h1>哈哈哈哈</h1><h2>嘿嘿嘿嘿</h2></div>
2.2. decode html元素反转义
import{decode}from'@clownlee/utils';consttext='<div><h1>哈哈哈哈</h1><h2>嘿嘿嘿嘿</h2></div>'consthtml=decode(text)// html = <div><h1>哈哈哈哈</h1><h2>嘿嘿嘿嘿</h2></div>
import{SM4}from'@clownlee/utils';letsm4Config={// encrypt/decypt main key; cannot be omittedkey: 'JeF8U9wHFOMfs2Y8',// optional; can be 'cbc' or 'ecb'mode: 'cbc',// default// optional; when use cbc mode, it's necessaryiv: 'UISwD9fW6cFh9SNS',// default is null// optional: this is the cipher data's type; Can be 'base64' or 'text'cipherType: 'base64'// default is base64};letsm4=newSM4(sm4Config);// Encryptletplaintext='中国国密加解密算法'letciphertext=sm4.encrypt(plaintext)// ciphertext's result is 'j/+HgSpv8RZQI2YtSq0L1RnemiSokMm1VvLHSTt245U='// Decryptletciphertext='j/+HgSpv8RZQI2YtSq0L1RnemiSokMm1VvLHSTt245U='letplaintext=sm4.decrypt(ciphertext)// plaintext's result is '中国国密加解密算法'