生成,并记录一个随机数。将要转换的字符变成成ASC代码,根据生成的随机数,取第n位就行了。
解决方案 »
- 如何读取数据库的元数据?
- 运行抱错!急!!!!!!!
- 关于SPCOMM控件参数的设置.
- 急用!在edit中输入金额,如何控制只能输入到小数点后两位!
- 如何得到OpenDialog所打开文件的大小,在edit1.text中显示出来
- 在表里如果一个字段都是重复出现的几种值,如何用sql 选出这几种值?
- 如何编写由程序动态生成的控件的事件?
- 请问:怎么才能让Label控件始终在最上面,而不被别的控件挡住?
- 请各路英雄进去帮帮忙吧http://www.csdn.net/expert/topicview1.asp
- 怎样让DBGrid在按住Shift点鼠标的同时能将连续范围的多行选中?
- 如何限制只能输入小数点后俩位,多于俩位的不让它输入?
- 怎样动态地处理sql服务器的登录事件?
s,str1:string;
str:char;
k:integer;
begin
s:='tsinghua';
str1:='';
for i:=1 to length(s) do
str:=s[i];
k:=ord(str);
k:=K+2;
str1:=concat(str1,chr(k));
end;
//结果:str1='vukpijwc'哈哈,给分!!!!!!!!!!111
const
C1=88665; //两个密钥
C2=53419; //
function Encrypt(s:string;key:WORD):String;implementation
function Encrypt(s:string;key:WORD):String;
var
I:Byte;
slen:integer;
res:string;
begin
slen:= Length(s);
setlength(s,slen);
setlength(res,slen);
for i:=1 to slen do begin
Res[i] := char(byte(s[i]) xor (key shr 8));
key :=(byte(Res[i])+key)*C1+C2;
end;
result := res;
end;如: ENCRYPT('This is a car',56788); key=56788.
[email protected]
{
*************************************************************************
* Name: Crypt32.Pas *
* Description: 32 bits encode/decode module *
* 2^96 variants it is very high to try hack *
* Purpose: Good for encrypting passwors and text *
* Security: avoid use StartKey less than 256 *
* if it use only for internal use you may use default *
* key, but MODIFY unit before compiling *
* Call: Encrypted := Encrypt(InString,StartKey,MultKey,AddKey) *
* Decrypted := Decrypt(InString,StartKey) *
* Parameters: InString = long string (max 2 GB) that need to encrypt *
* decrypt *
* MultKey = MultKey key *
* AddKey = Second key *
* StartKey = Third key *
* (posible use defaults from interface) *
* Return: OutString = result string *
* Editor: Besr viewed with Tab stops = 2, Courier new *
* Started: 01.08.1996 *
* Revision: 22.05.1997 - ver.2.01 converted from Delphi 1 *
* and made all keys as parameters, before only start key *
* Platform: Delphi 2.0, 3.0 *
* work in Delphi 1.0, 2^48 variants, 0..255 strings *
* Author: Anatoly Podgoretsky *
* Base alghoritm from Borland *
* Address: Vahe 4-31, Johvi, Estonia, EE2045, tel. 61-142 *
* [email protected] *
* Status: Freeware, but any sponsor help will be appreciated here *
* need to buy books, shareware products, tools etc *
*************************************************************************
* Modified: Supports Delphi 1.0 & 2.0 *
* Overflow checking removed *
* By: Martin Djern鎠 *
* e-mail: [email protected] *
* web: einstein.ot.dk/~djernaes *
*************************************************************************
}
interfaceconst
StartKey = 981; {Start default key}
MultKey = 12674; {Mult default key}
AddKey = 35891; {Add default key}function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;implementation{$R-}
{$Q-}
{*******************************************************
* Standard Encryption algorithm - Copied from Borland *
*******************************************************}
function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
var
I : Byte;
begin
Result := '';
for I := 1 to Length(InString) do
begin
Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
StartKey := (Byte(Result[I]) + StartKey) * MultKey + AddKey;
end;
end;
{*******************************************************
* Standard Decryption algorithm - Copied from Borland *
*******************************************************}
function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
var
I : Byte;
begin
Result := '';
for I := 1 to Length(InString) do
begin
Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
StartKey := (Byte(InString[I]) + StartKey) * MultKey + AddKey;
end;
end;
{$R+}
{$Q+}end.