gmCrypt.ts 472 B

12345678910111213141516171819202122232425
  1. import { sm4 } from 'sm-crypto'
  2. const default_hexKey = '86C63180C2806ED1F47B859DE501215B'
  3. /*
  4. * text 待加密文本
  5. */
  6. export function encrypt(text) {
  7. const encrypt = sm4.encrypt(text, default_hexKey,{ mode: 'ecb', padding: 'pkcs#7' })
  8. return encrypt
  9. }
  10. /*
  11. * text 待解密密文
  12. */
  13. export function decrypt(text) {
  14. const decrypt = sm4.decrypt(text, default_hexKey,{ mode: 'ecb', padding: 'pkcs#7' })
  15. return decrypt
  16. }
  17. export default {
  18. encrypt,
  19. decrypt
  20. }