资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

如何对任意字符文本进行加密

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

如何对任意字符文本进行加密,包括文本与标点字母大小写等内容符号,还原时再还原为原来内容,

网友回答:

发表者:starsoulxp

加密字符串算法    
   
  作者:junk.Damage.Case  
   
   
  This   is   an   example   of   REAL   encryption.   Not   that   ASCII   addition/subtraction   junk.Damage.Case   http://www.alchemydev.com/  
   
   
  Just   put   this   in   a   form.   And   figure   out   how   to    
   
  call   them   yourself.  
   
   
  This   is   how   encryption   is   done   boys   and   girls.  
   
  Im   sick   of   seeing   posts   of   encryption   routines  
   
  that   add   and   subtract   to   the   ascii   number   of   a  
   
  character.   Its   very   ineffective.   Decryption  
   
  programs   can   crack   simple   stuff   like   that   in  
   
  less   than   a   second.   Do   it   right.  
   
   
  Note:   Dont   make   the   key   repetative   in   any   way!  
   
   
  Option   Explicit  
   
   
  Private   Function   Decrypt(PlainStr   As   String,   key   As   String)  
   
  Dim   Char   As   String,   KeyChar   As   String,   NewStr   As   String  
   
  Dim   Pos   As   Integer  
   
  Dim   i   As   Integer,   Side1   As   String,   Side2   As   String  
   
  Pos   =   1  
   
   
  This   is   a   little   trick   to   make   it   slightly   harder   to   crack.  
   
  However,   the   chances   of   this   operation   firing   is   50/50  
   
  because   the   length   of   the   string   must   be   divisable   by   2.  
   
  If   Len(PlainStr)   Mod   2   =   0   Then  
   
    Side1   =   StrReverse(Left(PlainStr,   (Len(PlainStr)   /   2)))  
   
    Side2   =   StrReverse(Right(PlainStr,   (Len(PlainStr)   /   2)))  
   
    PlainStr   =   Side1   &   Side2  
   
  End   If  
   
   
  This   loop   decrypts   the   data.  
   
  For   i   =   1   To   Len(PlainStr)  
   
    Char   =   Mid(PlainStr,   i,   1)  
   
    KeyChar   =   Mid(key,   Pos,   1)  
   
    NewStr   =   NewStr   &   Chr(Asc(Char)   Xor   Asc(KeyChar))  
   
    If   Pos   =   Len(key)   Then   Pos   =   0  
   
    Pos   =   Pos   +   1  
   
  Next   i  
   
   
  Decrypt   =   NewStr  
   
  End   Function  
   
   
  Private   Function   Encrypt(PlainStr   As   String,   key   As   String)  
   
  Dim   Char   As   String,   KeyChar   As   String,   NewStr   As   String  
   
  Dim   Pos   As   Integer  
   
  Dim   i   As   Integer,   Side1   As   String,   Side2   As   String  
   
  Pos   =   1  
   
   
  This   loop   encrypts   the   data.  
   
  For   i   =   1   To   Len(PlainStr)  
   
    Char   =   Mid(PlainStr,   i,   1)  
   
    KeyChar   =   Mid(key,   Pos,   1)  
   
    NewStr   =   NewStr   &   Chr(Asc(Char)   Xor   Asc(KeyChar))  
   
    If   Pos   =   Len(key)   Then   Pos   =   0  
   
    Pos   =   Pos   +   1  
   
  Next   i  
   
   
  This   is   a   little   trick   to   make   it   slightly   harder   to   crack.  
   
  However,   the   chances   of   this   operation   firing   is   50/50  
   
  because   the   length   of   the   string   must   be   divisable   by   2.  
   
  If   Len(NewStr)   Mod   2   =   0   Then  
   
    Side1   =   StrReverse(Left(NewStr,   (Len(NewStr)   /   2)))  
   
    Side2   =   StrReverse(Right(NewStr,   (Len(NewStr)   /   2)))  
   
    NewStr   =   Side1   &   Side2  
   
  End   If  
   
   
  Encrypt   =   NewStr  
   
  End   Function    
   
 


 

 
热门推荐笔记本: 腾龙笔记本
相关文章:
笔记本相关:
IT技术文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved