打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
pb的文本加密和解密函数(II)

pb的文本加密和解密函数

默认分类 2008-04-16 11:44:37 阅读41 评论0   字号: 订阅

  //加密码,argument   name:  
  //as_pass,需加密字符串  
  //as_flag=0:加密   as_flag=1:解密  
  //  
  Int   li_pos,li_count1,li_EpassLast,li_Asc,li_Epass[]  
  String   ls_pass 
  string as_pass
  int as_flag
  
  If   as_flag   =   0   Then  
  //转换字符串为二进制码  
  li_EpassLast=0  
  For   li_pos=1   To   Len(as_pass)  
      li_Asc=Int(Asc(Mid(as_pass,li_pos,1)))  
      For   li_count1=7   To   0   Step   -1  
        li_EpassLast   ++  
        If   li_Asc   >=   2^li_count1   Then  
          li_Epass[li_EpassLast]=1  
        Else  
          li_Epass[li_EpassLast]=0  
        End   if        
        li_Asc=Mod(li_Asc,2^li_count1)  
      Next  
  Next  
  //二进制码换位  
  For   li_pos=1   To   Int(li_EpassLast   /   2)  
      li_Asc=li_Epass[li_pos]  
      li_Epass[li_pos]=li_Epass[li_EpassLast   +   1   -   li_pos]  
      li_Epass[li_EpassLast   +1   -   li_pos]=li_Asc  
  Next  
  //已前半部二进制码异或后半部二进制  
  For   li_pos=1   To   Int(li_EpassLast   /   2)  
      If   li_Epass[li_pos]   =   1   Then  
        li_Epass[li_EpassLast   +   1   -   li_pos]=abs(li_Epass[li_EpassLast   +   1   -   li_pos]   -   1)  
      End   if      
  Next  
  Else   //以上过程之逆过程  
  li_EpassLast=0  
  For   li_pos=1   To   Len(as_pass)  
      li_Asc=Int(Asc(Mid(as_pass,li_pos,1)))-48  
      For   li_count1=3   To   0   Step   -1  
        li_EpassLast   ++  
        If   li_Asc   >=   2^li_count1   Then  
          li_Epass[li_EpassLast]=1  
        Else  
          li_Epass[li_EpassLast]=0  
        End   if        
        li_Asc=Mod(li_Asc,2^li_count1)  
      Next  
  Next  
  For   li_pos=1   To   Int(li_EpassLast   /   2)  
      If   li_Epass[li_pos]   =   1   Then  
        li_Epass[li_EpassLast   +   1   -   li_pos]=abs(li_Epass[li_EpassLast   +   1   -   li_pos]   -   1)  
      End   if      
  Next  
   
  For   li_pos=1   To   Int(li_EpassLast   /   2)  
      li_Asc=li_Epass[li_pos]  
      li_Epass[li_pos]=li_Epass[li_EpassLast   +   1   -   li_pos]  
      li_Epass[li_EpassLast   +1   -   li_pos]=li_Asc  
  Next  
  End   if  
  //转换二进制码为字符串  
  If   as_flag   =   0   Then  
  li_count1=3  
  Else  
  li_count1=7  
  End   if  
  ls_pass=""  
  li_Asc=0  
  For   li_pos=1   To   li_EpassLast  
  li_Asc=li_Asc+2^li_count1*li_Epass[li_pos]  
  li_count1   --  
  If   li_count1=-1   Then    
      If   as_flag   =   0   Then  
        ls_pass=ls_Pass+Char(li_Asc+48)  
        li_count1=3  
      Else    
        ls_pass=ls_Pass+Char(li_Asc)  
        li_count1=7  
      End   if  
      li_Asc=0  
  End   if  
  Next   
  
  return   ls_pass    
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
2014高考试题及答案-文科数学-新课标II-1
数学符号大全
02302006高考数学陕西理科卷word版
党性_人民性的话语起源与行动逻辑_李冉[1]
VFP 多用户权限设置实例
广东省历年高考理科数学试卷及答案(05年—11年)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服