马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
global type f_encrypt from function_object
end type
forward prototypes
global function string f_encrypt (string st_text, string st_key)
end prototypes
global function string f_encrypt (string st_text, string st_key);//**************************************************************
// Function: uf_pub_encrypt() *
// Descirption: 用给定的密钥加密字符串 *
// Parameters: string st_text 待加密字串 *
// string st_key 密钥 *
// *
// Return: <加密后字串> *
// *
// Author: rain *
// Date: 2002.11.05 *
//**************************************************************
string st_textencrypt
long lg_textlen,lg_keylen,lg_key
long lg_loop
IF isnull(st_key) OR isnull(st_text) THEN RETURN ''
lg_keylen = len(st_key)
FOR lg_loop = 1 TO lg_keylen
lg_key = lg_key + (asc(mid(st_key,lg_loop,1)) * lg_loop)
IF lg_key > 255 THEN lg_key = lg_key - 255
NEXT
DO While lg_key > 255
lg_key = lg_key - 255
LOOP
LONG lg_cbyte
lg_textlen = Len(st_text)
FOR lg_loop = 1 TO lg_textlen
lg_cbyte = asc(mid(st_text,lg_loop,1)) + lg_key
IF lg_cbyte > 255 THEN lg_cbyte = lg_cbyte - 255
st_textencrypt = st_textencrypt + char(lg_cbyte)
lg_key = lg_key + lg_cbyte
IF lg_key > 255 THEN lg_key = lg_key - 255
NEXT
RETURN st_textencrypt
end function
//解密
global type f_decrypt from function_object
end type
forward prototypes
global function string f_decrypt (string st_text, string st_key)
end prototypes
global function string f_decrypt (string st_text, string st_key);//**************************************************************
// Function: uf_pub_decrypt() *
// Descirption: 用给定的密钥解密字符串,与uf_pub_encrypt相对 *
// Parameters: string st_text 待解密字串 *
// string st_key 密钥 *
// *
// Return: <解密后字串> *
// *
// Author: rain *
// Date: 2002.11.05 *
//**************************************************************
string st_textdecrypt
IF isnull(st_key) OR isnull(st_text) THEN RETURN ''
long lg_textlen,lg_keylen,lg_key
long lg_loop
lg_keylen = len(st_key)
FOR lg_loop = 1 TO lg_keylen
lg_key = lg_key + (asc(mid(st_key,lg_loop,1)) * lg_loop)
IF lg_key>255 THEN lg_key = lg_key - 255
NEXT
DO While lg_key>255
lg_key = lg_key - 255
LOOP
lg_textlen = len(st_text)
long lg_cbyte
FOR lg_loop = 1 TO lg_textlen
lg_cbyte = asc(mid(st_text,lg_loop,1)) - lg_key
IF lg_cbyte<0 THEN lg_cbyte = lg_cbyte + 255
st_textdecrypt = st_textdecrypt + char(lg_cbyte)
lg_key = lg_key + asc(mid(st_text,lg_loop,1))
IF lg_key > 255 THEN lg_key = lg_key - 255
NEXT
RETURN st_textdecrypt
end function
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sdrzths/archive/2009/01/20/3839177.aspx
来自上面,未测试 |