Skip to content

加密解密

内置 加密解密 工具函数

函数名描述类型参数返回值
MD5MD5加密(content:string)=> string(content:string)String
base64Base64编码(content:string)=> string(content:string)String
unBase64Base64解码(content:string)=> string(content:string)String
RSA非对称加密(RSA密钥对生成工具)(content:string,key:string)=> string(content:string,key:string)String
unRSA非对称解密(content:string,key:string)=> string(content:string,key:string)String
AES对称加密(content:string,key:string)=> string(content:string,key:string)String
unAES对称解密(content:string,key:string)=> string(content:string,key:string)String

示例

加密解密例子
函数名例子返回值
MD5MD5('Abc')35593b7ce5020eae3ca68fd5b6f3e031
base64base64('Abc')QWJj
unBase64unBase64(base64('Abc'))Abc
RSARSA('abc')RiLRlFiNz1z4KD/hJcAHrveShPZVYhi2PyRyZ/XwSawT7FEId7won2EnS4BA5X4t3uaAqJ06rkxE0uS9Yk0+zQ==
unRSAunRSA(RSA('abc'))abc
AES AES('abc', 'aaa') U2FsdGVkX1/txNtGCUtJnEljeZESj9g6OtXpDNsg7Bs=
unAESunAES(AES('abc', 'a'), 'a')abc

<template>
  <div>
    <config-table title="加密解密例子" :list="list"></config-table>
  </div>
</template>

<script setup lang="ts">
  import { MD5, base64, unBase64, RSA, unRSA, AES, unAES } from '@vtj/utils';
  import ConfigTable from '$/components/configTable.vue';

  const RSAVal: string = RSA('abc') as string;

  const AESVal = AES('abc', 'a');
  const val = unAES(AESVal, 'a');

  const list: any[] = [
    { name: 'MD5', example: "MD5('Abc')", return: MD5('Abc') },
    { name: 'base64', example: "base64('Abc')", return: base64('Abc') },
    {
      name: 'unBase64',
      example: "unBase64(base64('Abc'))",
      return: unBase64(base64('Abc'))
    },
    {
      name: 'RSA',
      example: "RSA('abc')",
      return: RSA('abc')
    },
    {
      name: 'unRSA',
      example: "unRSA(RSA('abc'))",
      return: unRSA(RSAVal)
    },
    {
      name: 'AES',
      example: " AES('abc', 'aaa') ",
      return: AES('abc', 'aaa')
    },
    {
      name: 'unAES',
      example: "unAES(AES('abc', 'a'), 'a')",
      return: val
    }
  ];
</script>

Released under the MIT License.