PHP中 base64_decode与base64_encode加密解密函数

base64_encode是加密

base64_encode    语法:string base64_encode(string data);

$string='www.zhix.net智昕网络'; //定义字符串

echo base64_encode($string);  // 输出编码后的内容为 d3d3LnpoaXgubmV05pm65piV572R57uc

base64_decode是解密 

base64_decode    语法:string base64_decode(string data);

$string='d3d3LnpoaXgubmV05pm65piV572R57uc';     //定义字符串

echo base64_decode($string); //输出解码后的内容 www.zhix.net智昕网络

 

 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ASP代码Base64加密和解密工具可以通过以下步骤实现。 加密: 1. 获取要加密的字符串。 2. 将字符串转换为字节数组。 3. 使用ASP代码Base64编码函数对字节数组进行编码。 4. 将编码后的字符串作为加密结果返回。 解密: 1. 获取已经加密的Base64字符串。 2. 使用ASP代码Base64解码函数将字符串解码为字节数组。 3. 将解码后的字节数组转换为字符串。 4. 将解密后的字符串作为解密结果返回。 示例代码如下: ``` ' 加密函数 Function Base64Encode(str) Dim bytes, enc ' 将字符串转换为字节数组 bytes = StrToByteArray(str) ' 使用Base64编码函数进行编码 Set enc = Server.CreateObject("System.Text.Encoding") Base64Encode = enc.EncodeBytes_64(bytes) End Function ' 解密函数 Function Base64Decode(str) Dim bytes, enc ' 使用Base64解码函数进行解码 Set enc = Server.CreateObject("System.Text.Encoding") bytes = enc.DecodeBytes_64(str) ' 将字节数组转换为字符串 Base64Decode = ByteArrayToStr(bytes) End Function ' 将字符串转换为字节数组 Function StrToByteArray(str) Dim i, bytes ReDim bytes(Len(str) - 1) For i = 1 To Len(str) bytes(i - 1) = Asc(Mid(str, i, 1)) Next StrToByteArray = bytes End Function ' 将字节数组转换为字符串 Function ByteArrayToStr(bytes) Dim i, str For i = LBound(bytes) To UBound(bytes) str = str & Chr(bytes(i)) Next ByteArrayToStr = str End Function ``` 使用时,可以调用`Base64Encode`函数进行加密,以及调用`Base64Decode`函数进行解密。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值