软件的加密(200分)

  • 主题发起人 主题发起人 zhaoshuming
  • 开始时间 开始时间
Z

zhaoshuming

Unregistered / Unconfirmed
GUEST, unregistred user!
急求算法或程序(限DELPHI)。用于生成序列号。
要求输入一个中文字符(如“浙江省杭州市”),输出一串序列号。
输出的序列号可以是纯数字,也可以是数字与字符的混合。(至少10位)
虽然我也知道对于程序员,最重要的是写好程序,但是我认为就目前的
国情,加密还是有一定的必要的。
希望有现成算法或程序的朋友,或者能够自己写一个的朋友,能够慷慨解囊!
万分感谢!
 
我的师兄做加密的,有个软件在国外很多网站评为5星
主页: www.ultraprotect.com
你可以下载一个,不过要注册的,你可以给他写封信试试,看他能不能给你一个免费注册号
不过如果不是很大的工程,我看在初期还是不要加密的太狠,你看M$都有这么多盗版,
我想一定程度上它是想让你盗的,如果有人盗了我的软件,我得去庆祝一下了
如果有空:
http://easyinfo.5188.org,
做电子相册和通讯录的软件,
我没用师兄的加密,因为他的加密可能无人解得了
 
自己写一个加密算法,如果太懒的话,问我要一个
 
找个加密的软件吧
www.playicq.com
上面有
 
DESCrypt加密算法
unit DESCrypt;
interface
uses
SysUtils,Classes;
type
TByte32 = array[1..32] of Byte;
TSData = array[0..63] of Byte;
TBlock = array[0..7] of Byte;

function EnCryptStr(aStr: string;
aKey: string ): string;
function DeCryptStr(aStr: string;
aKey: string ): string;
function EnCrypt(in_buf:Tblock;
aKey: string = '19711203'): Tblock;
function DeCrypt(in_buf:Tblock;
aKey: string = '19711203'): Tblock;
procedure EnCryptFile(infile,outfile: string;
aKey: string );
procedure DECryptFile(infile,outfile: string;
aKey: string );
implementation

const
SA1: TSData =
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1,
0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1);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, 1, 0, 1, 0, 0, 1, 0,
1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1);
Sc: array[1..16, 1..48] of Byte =
((15, 18, 12, 25, 2, 6, 4, 1, 16, 7, 22, 11, 24, 20, 13, 5, 27, 9, 17, 8, 28, 21, 14, 3,
42, 53, 32, 38, 48, 56, 31, 41, 52, 46, 34, 49, 45, 50, 40, 29, 35, 54, 47, 43, 51, 37, 30, 33),
(16, 19, 13, 26, 3, 7, 5, 2, 17, 8, 23, 12, 25, 21, 14, 6, 28, 10, 18, 9, 1, 22, 15, 4,
43, 54, 33, 39, 49, 29, 32, 42, 53, 47, 35, 50, 46, 51, 41, 30, 36, 55, 48, 44, 52, 38, 31, 34),
(18, 21, 15, 28, 5, 9, 7, 4, 19, 10, 25, 14, 27, 23, 16, 8, 2, 12, 20, 11, 3, 24, 17, 6,
45, 56, 35, 41, 51, 31, 34, 44, 55, 49, 37, 52, 48, 53, 43, 32, 38, 29, 50, 46, 54, 40, 33, 36),
(20, 23, 17, 2, 7, 11, 9, 6, 21, 12, 27, 16, 1, 25, 18, 10, 4, 14, 22, 13, 5, 26, 19, 8,
47, 30, 37, 43, 53, 33, 36, 46, 29, 51, 39, 54, 50, 55, 45, 34, 40, 31, 52, 48, 56, 42, 35, 38),
(22, 25, 19, 4, 9, 13, 11, 8, 23, 14, 1, 18, 3, 27, 20, 12, 6, 16, 24, 15, 7, 28, 21, 10,
49, 32, 39, 45, 55, 35, 38, 48, 31, 53, 41, 56, 52, 29, 47, 36, 42, 33, 54, 50, 30, 44, 37, 40),
(24, 27, 21, 6, 11, 15, 13, 10, 25, 16, 3, 20, 5, 1, 22, 14, 8, 18, 26, 17, 9, 2, 23, 12,
51, 34, 41, 47, 29, 37, 40, 50, 33, 55, 43, 30, 54, 31, 49, 38, 44, 35, 56, 52, 32, 46, 39, 42),
(26, 1, 23, 8, 13, 17, 15, 12, 27, 18, 5, 22, 7, 3, 24, 16, 10, 20, 28, 19, 11, 4, 25, 14,
53, 36, 43, 49, 31, 39, 42, 52, 35, 29, 45, 32, 56, 33, 51, 40, 46, 37, 30, 54, 34, 48, 41, 44),
(28, 3, 25, 10, 15, 19, 17, 14, 1, 20, 7, 24, 9, 5, 26, 18, 12, 22, 2, 21, 13, 6, 27, 16,
55, 38, 45, 51, 33, 41, 44, 54, 37, 31, 47, 34, 30, 35, 53, 42, 48, 39, 32, 56, 36, 50, 43, 46),
(1, 4, 26, 11, 16, 20, 18, 15, 2, 21, 8, 25, 10, 6, 27, 19, 13, 23, 3, 22, 14, 7, 28, 17,
56, 39, 46, 52, 34, 42, 45, 55, 38, 32, 48, 35, 31, 36, 54, 43, 49, 40, 33, 29, 37, 51, 44, 47),
(3, 6, 28, 13, 18, 22, 20, 17, 4, 23, 10, 27, 12, 8, 1, 21, 15, 25, 5, 24, 16, 9, 2, 19,
30, 41, 48, 54, 36, 44, 47, 29, 40, 34, 50, 37, 33, 38, 56, 45, 51, 42, 35, 31, 39, 53, 46, 49),
(5, 8, 2, 15, 20, 24, 22, 19, 6, 25, 12, 1, 14, 10, 3, 23, 17, 27, 7, 26, 18, 11, 4, 21,
32, 43, 50, 56, 38, 46, 49, 31, 42, 36, 52, 39, 35, 40, 30, 47, 53, 44, 37, 33, 41, 55, 48, 51),
(7, 10, 4, 17, 22, 26, 24, 21, 8, 27, 14, 3, 16, 12, 5, 25, 19, 1, 9, 28, 20, 13, 6, 23,
34, 45, 52, 30, 40, 48, 51, 33, 44, 38, 54, 41, 37, 42, 32, 49, 55, 46, 39, 35, 43, 29, 50, 53),
(9, 12, 6, 19, 24, 28, 26, 23, 10, 1, 16, 5, 18, 14, 7, 27, 21, 3, 11, 2, 22, 15, 8, 25,
36, 47, 54, 32, 42, 50, 53, 35, 46, 40, 56, 43, 39, 44, 34, 51, 29, 48, 41, 37, 45, 31, 52, 55),
(11, 14, 8, 21, 26, 2, 28, 25, 12, 3, 18, 7, 20, 16, 9, 1, 23, 5, 13, 4, 24, 17, 10, 27,
38, 49, 56, 34, 44, 52, 55, 37, 48, 42, 30, 45, 41, 46, 36, 53, 31, 50, 43, 39, 47, 33, 54, 29),
(13, 16, 10, 23, 28, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 56, 31),
(14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32));
var
G: array[1..16, 1..48] of Byte;
L, R, F: TByte32;
C: array[1..56] of Byte;
//对转换后的密码进行置换
procedure DES_Init(Key: TBlock;
FCode: Boolean);
var
n, h: Byte;
begin
C[1] := Ord(Key[7] and 128 > 0);
C[29] := Ord(Key[7] and 2 > 0);
C[2] := Ord(Key[6] and 128 > 0);
C[30] := Ord(Key[6] and 2 > 0);
C[3] := Ord(Key[5] and 128 > 0);
C[31] := Ord(Key[5] and 2 > 0);
C[4] := Ord(Key[4] and 128 > 0);
C[32] := Ord(Key[4] and 2 > 0);
C[5] := Ord(Key[3] and 128 > 0);
C[33] := Ord(Key[3] and 2 > 0);
C[6] := Ord(Key[2] and 128 > 0);
C[34] := Ord(Key[2] and 2 > 0);
C[7] := Ord(Key[1] and 128 > 0);
C[35] := Ord(Key[1] and 2 > 0);
C[8] := Ord(Key[0] and 128 > 0);
C[36] := Ord(Key[0] and 2 > 0);
C[9] := Ord(Key[7] and 64 > 0);
C[37] := Ord(Key[7] and 4 > 0);
C[10] := Ord(Key[6] and 64 > 0);
C[38] := Ord(Key[6] and 4 > 0);
C[11] := Ord(Key[5] and 64 > 0);
C[39] := Ord(Key[5] and 4 > 0);
C[12] := Ord(Key[4] and 64 > 0);
C[40] := Ord(Key[4] and 4 > 0);
C[13] := Ord(Key[3] and 64 > 0);
C[41] := Ord(Key[3] and 4 > 0);
C[14] := Ord(Key[2] and 64 > 0);
C[42] := Ord(Key[2] and 4 > 0);
C[15] := Ord(Key[1] and 64 > 0);
C[43] := Ord(Key[1] and 4 > 0);
C[16] := Ord(Key[0] and 64 > 0);
C[44] := Ord(Key[0] and 4 > 0);
C[17] := Ord(Key[7] and 32 > 0);
C[45] := Ord(Key[7] and 8 > 0);
C[18] := Ord(Key[6] and 32 > 0);
C[46] := Ord(Key[6] and 8 > 0);
C[19] := Ord(Key[5] and 32 > 0);
C[47] := Ord(Key[5] and 8 > 0);
C[20] := Ord(Key[4] and 32 > 0);
C[48] := Ord(Key[4] and 8 > 0);
C[21] := Ord(Key[3] and 32 > 0);
C[49] := Ord(Key[3] and 8 > 0);
C[22] := Ord(Key[2] and 32 > 0);
C[50] := Ord(Key[2] and 8 > 0);
C[23] := Ord(Key[1] and 32 > 0);
C[51] := Ord(Key[1] and 8 > 0);
C[24] := Ord(Key[0] and 32 > 0);
C[52] := Ord(Key[0] and 8 > 0);
C[25] := Ord(Key[7] and 16 > 0);
C[53] := Ord(Key[3] and 16 > 0);
C[26] := Ord(Key[6] and 16 > 0);
C[54] := Ord(Key[2] and 16 > 0);
C[27] := Ord(Key[5] and 16 > 0);
C[55] := Ord(Key[1] and 16 > 0);
C[28] := Ord(Key[4] and 16 > 0);
C[56] := Ord(Key[0] and 16 > 0);
if FCode then
begin
for n := 1 to 16do
begin
for h := 1 to 48do
begin
G[n, h] := C[Sc[n, h]];
end;
end;
end
else
begin
for n := 1 to 16do
begin
for h := 1 to 48do
begin
G[17 - n, h] := C[Sc[n, h]];
end;
end;
end;
end;

//对输入的8字节数据加密/解密
procedure DES_Code(Input: TBlock;
var Output: TBlock);
var
n: Byte;
z: Word;
begin
L[1] := Ord(Input[7] and 64 > 0);
R[1] := Ord(Input[7] and 128 > 0);
L[2] := Ord(Input[6] and 64 > 0);
R[2] := Ord(Input[6] and 128 > 0);
L[3] := Ord(Input[5] and 64 > 0);
R[3] := Ord(Input[5] and 128 > 0);
L[4] := Ord(Input[4] and 64 > 0);
R[4] := Ord(Input[4] and 128 > 0);
L[5] := Ord(Input[3] and 64 > 0);
R[5] := Ord(Input[3] and 128 > 0);
L[6] := Ord(Input[2] and 64 > 0);
R[6] := Ord(Input[2] and 128 > 0);
L[7] := Ord(Input[1] and 64 > 0);
R[7] := Ord(Input[1] and 128 > 0);
L[8] := Ord(Input[0] and 64 > 0);
R[8] := Ord(Input[0] and 128 > 0);
L[9] := Ord(Input[7] and 16 > 0);
R[9] := Ord(Input[7] and 32 > 0);
L[10] := Ord(Input[6] and 16 > 0);
R[10] := Ord(Input[6] and 32 > 0);
L[11] := Ord(Input[5] and 16 > 0);
R[11] := Ord(Input[5] and 32 > 0);
L[12] := Ord(Input[4] and 16 > 0);
R[12] := Ord(Input[4] and 32 > 0);
L[13] := Ord(Input[3] and 16 > 0);
R[13] := Ord(Input[3] and 32 > 0);
L[14] := Ord(Input[2] and 16 > 0);
R[14] := Ord(Input[2] and 32 > 0);
L[15] := Ord(Input[1] and 16 > 0);
R[15] := Ord(Input[1] and 32 > 0);
L[16] := Ord(Input[0] and 16 > 0);
R[16] := Ord(Input[0] and 32 > 0);
L[17] := Ord(Input[7] and 4 > 0);
R[17] := Ord(Input[7] and 8 > 0);
L[18] := Ord(Input[6] and 4 > 0);
R[18] := Ord(Input[6] and 8 > 0);
L[19] := Ord(Input[5] and 4 > 0);
R[19] := Ord(Input[5] and 8 > 0);
L[20] := Ord(Input[4] and 4 > 0);
R[20] := Ord(Input[4] and 8 > 0);
L[21] := Ord(Input[3] and 4 > 0);
R[21] := Ord(Input[3] and 8 > 0);
L[22] := Ord(Input[2] and 4 > 0);
R[22] := Ord(Input[2] and 8 > 0);
L[23] := Ord(Input[1] and 4 > 0);
R[23] := Ord(Input[1] and 8 > 0);
L[24] := Ord(Input[0] and 4 > 0);
R[24] := Ord(Input[0] and 8 > 0);
L[25] := Input[7] and 1;
R[25] := Ord(Input[7] and 2 > 0);
L[26] := Input[6] and 1;
R[26] := Ord(Input[6] and 2 > 0);
L[27] := Input[5] and 1;
R[27] := Ord(Input[5] and 2 > 0);
L[28] := Input[4] and 1;
R[28] := Ord(Input[4] and 2 > 0);
L[29] := Input[3] and 1;
R[29] := Ord(Input[3] and 2 > 0);
L[30] := Input[2] and 1;
R[30] := Ord(Input[2] and 2 > 0);
L[31] := Input[1] and 1;
R[31] := Ord(Input[1] and 2 > 0);
L[32] := Input[0] and 1;
R[32] := Ord(Input[0] and 2 > 0);
for n := 1 to 16do
begin
z := ((R[32] xor G[n, 1]) shl 5) or ((R[5] xor G[n, 6]) shl 4)
or ((R[ 1] xor G[n, 2]) shl 3) or ((R[2] xor G[n, 3]) shl 2)
or ((R[ 3] xor G[n, 4]) shl 1) or ( R[4] xor G[n, 5]);
F[ 9] := L[ 9] xor SA1[z];
F[17] := L[17] xor SB1[z];
F[23] := L[23] xor SC1[z];
F[31] := L[31] xor SD1[z];
z := ((R[4] xor G[n, 7]) shl 5) or ((R[9] xor G[n, 12]) shl 4)
or ((R[5] xor G[n, 8]) shl 3) or ((R[6] xor G[n, 9]) shl 2)
or ((R[7] xor G[n, 10]) shl 1) or ( R[8] xor G[n, 11]);
F[13] := L[13] xor SA2[z];
F[28] := L[28] xor SB2[z];
F[ 2] := L[ 2] xor SC2[z];
F[18] := L[18] xor SD2[z];
z := ((R[ 8] xor G[n, 13]) shl 5) or ((R[13] xor G[n, 18]) shl 4)
or ((R[ 9] xor G[n, 14]) shl 3) or ((R[10] xor G[n, 15]) shl 2)
or ((R[11] xor G[n, 16]) shl 1) or ( R[12] xor G[n, 17]);
F[24] := L[24] xor SA3[z];
F[16] := L[16] xor SB3[z];
F[30] := L[30] xor SC3[z];
F[ 6] := L[ 6] xor SD3[z];
z := ((R[12] xor G[n, 19]) shl 5) or ((R[17] xor G[n, 24]) shl 4)
or ((R[13] xor G[n, 20]) shl 3) or ((R[14] xor G[n, 21]) shl 2)
or ((R[15] xor G[n, 22]) shl 1) or ( R[16] xor G[n, 23]);
F[26] := L[26] xor SA4[z];
F[20] := L[20] xor SB4[z];
F[10] := L[10] xor SC4[z];
F[ 1] := L[ 1] xor SD4[z];
z := ((R[16] xor G[n, 25]) shl 5) or ((R[21] xor G[n, 30]) shl 4)
or ((R[17] xor G[n, 26]) shl 3) or ((R[18] xor G[n, 27]) shl 2)
or ((R[19] xor G[n, 28]) shl 1) or ( R[20] xor G[n, 29]);
F[ 8] := L[ 8] xor SA5[z];
F[14] := L[14] xor SB5[z];
F[25] := L[25] xor SC5[z];
F[ 3] := L[ 3] xor SD5[z];
z := ((R[20] xor G[n, 31]) shl 5) or ((R[25] xor G[n, 36]) shl 4)
or ((R[21] xor G[n, 32]) shl 3) or ((R[22] xor G[n, 33]) shl 2)
or ((R[23] xor G[n, 34]) shl 1) or ( R[24] xor G[n, 35]);
F[ 4] := L[ 4] xor SA6[z];
F[29] := L[29] xor SB6[z];
F[11] := L[11] xor SC6[z];
F[19] := L[19] xor SD6[z];
z := ((R[24] xor G[n, 37]) shl 5) or ((R[29] xor G[n, 42]) shl 4)
or ((R[25] xor G[n, 38]) shl 3) or ((R[26] xor G[n, 39]) shl 2)
or ((R[27] xor G[n, 40]) shl 1) or ( R[28] xor G[n, 41]);
F[32] := L[32] xor SA7[z];
F[12] := L[12] xor SB7[z];
F[22] := L[22] xor SC7[z];
F[ 7] := L[ 7] xor SD7[z];
z := ((R[28] xor G[n, 43]) shl 5) or ((R[ 1] xor G[n, 48]) shl 4)
or ((R[29] xor G[n, 44]) shl 3) or ((R[30] xor G[n, 45]) shl 2)
or ((R[31] xor G[n, 46]) shl 1) or ( R[32] xor G[n, 47]);
F[ 5] := L[ 5] xor SA8[z];
F[27] := L[27] xor SB8[z];
F[15] := L[15] xor SC8[z];
F[21] := L[21] xor SD8[z];
L := R;
R := F;
end;

Output[0] := (L[8] shl 7) or (R[8] shl 6) or (L[16] shl 5) or (R[16] shl 4)
or (L[24] shl 3) or (R[24] shl 2) or (L[32] shl 1) or R[32];
Output[1] := (L[7] shl 7) or (R[7] shl 6) or (L[15] shl 5) or (R[15] shl 4)
or (L[23] shl 3) or (R[23] shl 2) or (L[31] shl 1) or R[31];
Output[2] := (L[6] shl 7) or (R[6] shl 6) or (L[14] shl 5) or (R[14] shl 4)
or (L[22] shl 3) or (R[22] shl 2) or (L[30] shl 1) or R[30];
Output[3] := (L[5] shl 7) or (R[5] shl 6) or (L[13] shl 5) or (R[13] shl 4)
or (L[21] shl 3) or (R[21] shl 2) or (L[29] shl 1) or R[29];
Output[4] := (L[4] shl 7) or (R[4] shl 6) or (L[12] shl 5) or (R[12] shl 4)
or (L[20] shl 3) or (R[20] shl 2) or (L[28] shl 1) or R[28];
Output[5] := (L[3] shl 7) or (R[3] shl 6) or (L[11] shl 5) or (R[11] shl 4)
or (L[19] shl 3) or (R[19] shl 2) or (L[27] shl 1) or R[27];
Output[6] := (L[2] shl 7) or (R[2] shl 6) or (L[10] shl 5) or (R[10] shl 4)
or (L[18] shl 3) or (R[18] shl 2) or (L[26] shl 1) or R[26];
Output[7] := (L[1] shl 7) or (R[1] shl 6) or (L[9] shl 5) or (R[9] shl 4)
or (L[17] shl 3) or (R[17] shl 2) or (L[25] shl 1) or R[25];
end;

//把密码转换成8字节的数据
function StrToKey(aKey: string): TBlock;
var
Key : TBlock;
I : Integer;
begin
FillChar(Key, SizeOf(TBlock), 0);
for I := 1 to Length(aKey)do
begin
Key[I mod SizeOf(TBlock)] := Key[I mod SizeOf(TBlock)] + Ord(aKey);
end;
result := Key;
end;

//加密8字节的数据
function EnCrypt(in_Buf: Tblock;
aKey: string): TBlock;
var
WriteBuf: TBlock;
Key : TBlock;
begin
try
fillchar(writeBuf,8,0);
Key := StrToKey(aKey);
Des_Init(Key, True);
Des_Code(in_buf, WriteBuf);
result:=writebuf;
except
fillchar(writeBuf,8,0);
result:=writebuf;
end;
end;

//解密8字节的数据
function DeCrypt(in_buf: Tblock;
aKey: string):Tblock;
var
WriteBuf : TBlock;
Key : TBlock;
begin
try
Key := StrToKey(aKey);
Des_Init(Key, False);
FillChar(WriteBuf, 8, 0);
Des_Code(in_Buf, WriteBuf);
result :=WriteBuf;
except
FillChar(WriteBuf, 8, 0);
result :=WriteBuf;
end;
end;

//加密字符串
function EnCryptStr(aStr: string;
aKey: string): string;
var
ReadBuf : TBlock;
WriteBuf: TBlock;
Key : TBlock;
Count : Integer;
Offset : Integer;
I : Integer;
S : string;
begin
result := '';
Key := StrToKey(aKey);
Des_Init(Key, True);
Offset := 1;
Count := Length(aStr);
repeat
S := Copy(aStr, Offset, 8);
FillChar(ReadBuf, 8, 0);
Move(S[1], ReadBuf, Length(S));
Des_Code(ReadBuf, WriteBuf);
for I := 0 to 7do
begin
result := result + IntToHex(WriteBuf, 2);
end;
Offset := Offset + 8;
until Offset > ((Count+7) div 8) * 8;
end;

//解密字符串
function DeCryptStr(aStr: string;
aKey: string): string;
var
ReadBuf,
WriteBuf : TBlock;
Key : TBlock;
Offset : Integer;
Count : Integer;
I : Integer;
S : string;
begin
try
Key := StrToKey(aKey);
Des_Init(Key, False);
S := '';
I := 1;
repeat
S := S + Chr(StrToInt('$'+Copy(aStr, I, 2)));
Inc(I, 2);
until I > Length(aStr);
Offset := 1;
Count := Length(S);
while Offset < ((Count+7) div 8 * 8)do
begin
FillChar(ReadBuf, 8, 0);
Move(S[Offset], ReadBuf, 8);
Des_Code(ReadBuf, WriteBuf);
for I := 0 to 7do
begin
result := result + Chr(WriteBuf);
end;

Offset := Offset + 8;
end;
result := StrPas(PChar(result));
except
result := '';
end;
end;

//加密文件
procedure EnCryptFile(infile,outfile: string;
aKey: string );
var
ReadBuf : TBlock;
WriteBuf: TBlock;
LEN,len1,len2,I:INTEGER;
ms1,ms2:Tmemorystream;
begin
if (infile='') or (outfile='') or (akey='') then
exit;
try
ms1:=Tmemorystream.Create;
ms2:=Tmemorystream.Create;
ms1.LoadFromFile(infile);
//得到原始文件长度并按8的整数倍对齐
len:=ms1.Size;
len1 := ( len + 7 ) SHR 3;
// 按 8Bytes(64bits) 对齐
ms1.Size := len1 SHL 3;
len2:=ms1.Size;
ms1.Position:=0;
len1:=len2 div 8;
for i:=0 to len1-1do
begin
ms1.Read(Readbuf,8);
writebuf:=EnCrypt(readbuf,aKey);
ms2.Write(writebuf,8);
end;
//保存原始文件长度
ms2.Seek( 0, soFromEnd );
ms2.Write( len, SizeOf( len) );
// 将原始大小记录在数据末
ms2.SaveToFile(outfile);
ms1.Free;
ms2.Free;
except
ms1.Free;
ms2.Free;
end;
end;

//解密文件
procedure DeCryptFile(infile,outfile: string;
aKey: string );
var
ReadBuf,
WriteBuf : TBlock;
LEN,len1,len2,I:INTEGER;
ms1,ms2:Tmemorystream;
begin
if (infile='') or (outfile='') or (akey='') then
exit;
try
//加密
ms1:=Tmemorystream.Create;
ms2:=Tmemorystream.Create;
ms1.LoadFromFile(infile);
//得到原始文件长度len
len1 := SizeOf( len );
ms1.Seek( -len1, soFromEnd );
// 取得原始大小
ms1.Read( len, len1 );
len1 := ms1.Size - len1;
ms1.Size := len1;
len1 := ( len1 + 7 ) SHR 3;
// 按 8Bytes(64bits) 对齐
If ( ms1.Size <> ( len1 SHL 3 ) ) then
Raise Exception.Create( 'Invalid data size!' );
len1:=ms1.Size;
len1:=len1 div 8;
ms1.Position:=0;
ms2.Position:=0;
fillchar(readbuf,8,0);
for i:=0 to len1-1do
begin
ms1.Read(readbuf,8);
writebuf:=DeCrypt(readbuf,aKey);
ms2.Write(writebuf,8);
end;
ms2.SetSize(len);
ms2.SaveToFile(outfile);
ms1.Free;
ms2.Free;
except
ms1.Free;
ms2.Free;
end;
end;

end.

 
to f-h-s:
给我一个吧,谢谢。
to iloveqq:
谢谢你的算法,我还要看看。
其他朋友,有好的现成的算法,帮帮小弟阿。
 
unit uEncrypt;
interface
function Decrypt(const S: AnsiString;
Key: Word): AnsiString;
function Encrypt(const S: AnsiString;
Key: Word): AnsiString;
implementation
const
C1 = 52845;
C2 = 22719;
function Decode(const S: AnsiString): AnsiString;
const
Map: array[Char] of Byte = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0);
var
I: LongInt;
begin
case Length(S) of
2:
begin
I := Map[S[1]] + (Map[S[2]] shl 6);
SetLength(Result, 1);
Move(I, Result[1], Length(Result))
end;
3:
begin
I := Map[S[1]] + (Map[S[2]] shl 6) + (Map[S[3]] shl 12);
SetLength(Result, 2);
Move(I, Result[1], Length(Result));
end;
4:
begin
I := Map[S[1]] + (Map[S[2]] shl 6) + (Map[S[3]] shl 12) +
(Map[S[4]] shl 18);
SetLength(Result, 3);
Move(I, Result[1], Length(Result))
end
end
end;

function PreProcess(const S: AnsiString): AnsiString;
var
SS: AnsiString;
begin
SS := S;
Result := '';
while SS <> ''do
begin
Result := Result + Decode(Copy(SS, 1, 4));
Delete(SS, 1, 4)
end
end;

function InternalDecrypt(const S: AnsiString;
Key: Word): AnsiString;
var
I: Word;
Seed: Word;
begin
Result := S;
Seed := Key;
for I := 1 to Length(Result)do
begin
Result := Char(Byte(Result) xor (Seed shr 8));
Seed := (Byte(S) + Seed) * Word(C1) + Word(C2)
end
end;

function Decrypt(const S: AnsiString;
Key: Word): AnsiString;
begin
Result := InternalDecrypt(PreProcess(S), Key)
end;

function Encode(const S: AnsiString): AnsiString;
const
Map: array[0..63] of Char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz0123456789+/';
var
I: LongInt;
begin
I := 0;
Move(S[1], I, Length(S));
case Length(S) of
1:
Result := Map[I mod 64] + Map[(I shr 6) mod 64];
2:
Result := Map[I mod 64] + Map[(I shr 6) mod 64] +
Map[(I shr 12) mod 64];
3:
Result := Map[I mod 64] + Map[(I shr 6) mod 64] +
Map[(I shr 12) mod 64] + Map[(I shr 18) mod 64]
end
end;

function PostProcess(const S: AnsiString): AnsiString;
var
SS: AnsiString;
begin
SS := S;
Result := '';
while SS <> ''do
begin
Result := Result + Encode(Copy(SS, 1, 3));
Delete(SS, 1, 3)
end
end;

function InternalEncrypt(const S: AnsiString;
Key: Word): AnsiString;
var
I: Word;
Seed: Word;
begin
Result := S;
Seed := Key;
for I := 1 to Length(Result)do
begin
Result := Char(Byte(Result) xor (Seed shr 8));
Seed := (Byte(Result) + Seed) * Word(C1) + Word(C2)
end
end;

function Encrypt(const S: AnsiString;
Key: Word): AnsiString;
begin
Result := PostProcess(InternalEncrypt(S, Key))
end;

end.
 
光对密码加密是没有任何作用的,破解者仅把你的某一行汇编改掉就行,
重要的是对代码进行加密,反跟踪,随机地址等,我也不太懂,反正我的软件
《易信通》采用密码的方法已经当天出来,第二天就看到破解了,害得我最近都不想维护它了!
 
兄弟,我也要一份。谢谢了。baoyugang@0451.com
 
我的软件两天就被算出注册机了,我也要学习一下...晕
 
请大伙看一下我一软件演示版本,里面也有加密模块,自己编写的,看看谁能解密(肯
定可以解密),到时通知我一下就可以了:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2243199
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2269422
http://www.playicq.com/dispdocnew.php?id=10151
ftp://new:new12345@61.129.70.192:2100/control/200311031302002140.rar
只需要加入这个函数,就可以对付大部分调试软件(Softice,TRW2000,OllyDBG,W32DASM(调试功能)),
可以对付大部分监测软件,Filemon, RegMon,ExeSpy, ResSpy等
加了DLL之后的软件可用于win98,win2000等系统下,
我自已电脑测试过的有:
win98---trw2000 1.22 ;ollydbg 1.09b ;softice98 4.05;
w32dasm 8.93;filemon;regmon;winhex...
win2000---ollydbg 1.09b ;w32dasm 8.93;filemon;regmon;winhex...
kimlon@163.com
 
有个最简单的加密方法
function TransChar(AChar: Char): Integer;
begin

if AChar in ["0".."9"] then

Result := Ord(AChar) - Ord("0")
 else

 Result := 10 + Ord(AChar) - Ord("A");
end;

function StrToHex(AStr: string): string;
var
 I : Integer;
 Tmp: string;
begin

 Result := "";
 For I := 1 to Length(AStr)do

 begin

  Result := Result + Format("%2x", [Byte(AStr)]);
 end;

 I := Pos(" ", Result);
 While I <> 0do

 begin

  Result := "0";
  I := Pos(" ", Result);
 end;

end;

function HexToStr(AStr: string): string;
var
 I : Integer;
 CharValue: Word;
begin

 Result := "";
 For I := 1 to Trunc(Length(Astr)/2)do

 begin

 Result := Result + " ";
  CharValue := TransChar(AStr[2*I-1])*16 + TransChar(AStr[2*I]);
  Result := Char(CharValue);
 end;

end;

function Encrypt(const S: String;
Key: Word): String;
var
I : Integer;
begin

 Result := S;
 for I := 1 to Length(S)do

 begin

  Result := char(byte(S) xor (Key shr 8));
  Key := (byte(Result) + Key) * C1 + C2;
  if Result = Chr(0) then
Result := S;
 end;

 Result := StrToHex(Result);
end;

function Decrypt(const S: String;
Key: Word): String;
var
 I: Integer;
 S1: string;
begin

 S1 := HexToStr(S);
 Result := S1;
 for I := 1 to Length(S1)do
 
 begin

 if char(byte(S1) xor (Key shr 8)) = Chr(0) then

  begin

  Result := S1;
   Key := (byte(Chr(0)) + Key) * C1 + C2;
//保证Key的正确性  
end else

  begin

   Result := char(byte(S1) xor (Key shr 8));
   Key := (byte(S1) + Key) * C1 + C2;
  end;

 end;

end;
 
DELPHI程序注册码设计

  当你辛辛苦苦用DELPHI做好了一个你认为十分不错的程序,你是否想把它发布出去成为共享软件呢? 做为一个共享软件,注册码肯定是少不了的,你可以通过判断程序是否注册来进行功能,时间或一些其它限制.现在就介绍一种简单的注册码制造方法.思路是这样的:程序运行时先检测注册表,如果找到注册项,则表明已经注册,如果没有找到注册项,则提示要求注册.
<注册例程>
在DELPHI下新建一工程,放置Edit1,Edit2,Label1,Label2,Button1组件.具体代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry;//在此加上Registry以便调用注册表.
type
TForm1 = class(Tform)
Button1: Tbutton;
Edit1: Tedit;
Edit2: Tedit;
Label1: Tlabel;
Label2: Tlabel;
procedure Button1Click(Sender: Tobject);
procedure FormCreate(Sender: Tobject);
private
Function Check():Boolean;
Procedure CheckReg();
Procedure CreateReg();
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Pname:string;
//全局变量,存放用户名和注册码.
Ppass:integer;
implementation
{$R *.DFM}
Procedure TForm1.CreateReg();//创建用户信息.
var Rego:Tregistry;
begin
Rego:=Tregistry.Create;
Rego.RootKey:=HKEY_USERS;
rego.OpenKey('.DEFAULT/Software/AngelSoft/Demo',True);//键名为AngelSoft/Demo,可自行修改.
Rego.WriteString('Name',Pname);//写入用户名.
Rego.WriteInteger('Pass',Ppass);//写入注册码.
Rego.Free;
ShowMessage('程序已经注册,谢谢!');
CheckReg;
//刷新.
end;
Procedure TForm1.CheckReg();//检查程序是否在注册表中注册.
var Rego:Tregistry;
begin
Rego:=Tregistry.Create;
Rego.RootKey:=HKEY_USERS;
IF Rego.OpenKey('.DEFAULT/Software/AngelSoft/Demo',False) then
begin
Form1.Caption:='软件已经注册';
Button1.Enabled:=false;
Label1.Caption:=rego.ReadString('Name');//读用户名.
Label2.Caption:=IntToStr(Rego.ReadInteger('Pass'));
//读注册码.
rego.Free;
end
else
Form1.Caption:='软件未注册,请注册';
end;
Function TForm1.Check():Boolean;//检查注册码是否正确.
var
Temp:pchar;
Name:string;
c:char;
I,Long,Pass:integer;
begin
Pass:=0;
Name:=edit1.Text;
long:=length(Name);
for I:=1 to Longdo
begin
temp:=pchar(copy(Name,I,1));
c:=temp^;
Pass:=Pass+ord(c);
//将用户名每个字符转换为ASCII码后相加.
end;
if StrToInt(Edit2.Text)=pass then
begin
Result:=True;
Pname:=Name;
Ppass:=Pass;
end
else
Result:=False;
end;
procedure TForm1.Button1Click(Sender: Tobject);
begin
if Check then
CreateReg
else
ShowMessage('注册码不正确,无法注册');
end;
procedure TForm1.FormCreate(Sender: Tobject);
begin
CheckReg;
end;
end.
<注册器>
在DELPHI下新建一工程,放置Edit1,Edit2,Button1组件.具体代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(Tform)
Button1: Tbutton;
Edit1: Tedit;
Edit2: Tedit;
procedure Button1Click(Sender: Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: Tobject);
var
Temp:pchar;
Name:string;
c:char;
I,Long,Pass:integer;
begin
Pass:=0;
Name:=edit1.Text;
long:=length(Name);
for I:=1 to Longdo
begin
temp:=pchar(copy(Name,I,1));
c:=temp^;
Pass:=Pass+ord(c);
end;
edit2.text:=IntToStr(pass);
end;
end.
  从<注册器>中取得注册码,便可在<注册例程>中进行注册.原理是使用ORD函数取得用户名每单个字符的ASCII码值,并进行相加得到注册码.当然,这十分容易并破解,你可以用XOR进行异或操作,或者倒取反值...具体的要看你怎么实现了.总之,本文章只抛砖引玉罢了.
 
自己写吧
 
你参考一下这个贴子了
 
后退
顶部