line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Webqq::Encryption::TEA; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
3
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
4
|
1
|
|
|
1
|
|
574
|
use MIME::Base64 (); |
|
1
|
|
|
|
|
748
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
430
|
use Webqq::Encryption::TEA::Perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN{ |
8
|
1
|
|
|
1
|
|
2
|
eval{require JE;}; |
|
1
|
|
|
|
|
745
|
|
9
|
1
|
50
|
|
|
|
100105
|
$Webqq::Encryption::TEA::has_je = 1 unless $@; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub strToBytes{ |
13
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
14
|
|
|
|
|
|
|
#$str = join "",map {"\\x$_"} unpack "H2"x length($str),$str; |
15
|
0
|
|
|
|
|
|
my $return = ""; |
16
|
0
|
|
|
|
|
|
for(split //,$str){$return .= sprintf "%02x",ord($_)}; |
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#print qq# |
18
|
|
|
|
|
|
|
# var tea = TEA(); |
19
|
|
|
|
|
|
|
# var r = tea.strToBytes('$str'); |
20
|
|
|
|
|
|
|
# return(r); |
21
|
|
|
|
|
|
|
##; |
22
|
|
|
|
|
|
|
#$return = $je->eval(qq# |
23
|
|
|
|
|
|
|
# var tea = TEA(); |
24
|
|
|
|
|
|
|
# var r = tea.strToBytes('$str'); |
25
|
|
|
|
|
|
|
# return(r); |
26
|
|
|
|
|
|
|
##); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#croak $@ if $@; |
29
|
0
|
|
|
|
|
|
return $return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
sub _load_je{ |
32
|
0
|
|
|
0
|
|
|
my $je; |
33
|
0
|
0
|
|
|
|
|
croak "The JE module is not found, You may install it first\n" unless $Webqq::Encryption::TEA::has_je; |
34
|
0
|
0
|
|
|
|
|
if(defined $Webqq::Encryption::TEA::_je ){ |
35
|
0
|
|
|
|
|
|
$je = $Webqq::Encryption::TEA::_je ; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else{ |
38
|
0
|
|
|
|
|
|
my $javascript; |
39
|
0
|
0
|
|
|
|
|
if(defined $Webqq::Encryption::TEA::_javascript){ |
40
|
0
|
|
|
|
|
|
$javascript = $Webqq::Encryption::TEA::_javascript; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else{ |
43
|
0
|
|
|
|
|
|
local $/ = undef; |
44
|
0
|
|
|
|
|
|
$javascript = ; |
45
|
0
|
|
|
|
|
|
$Webqq::Encryption::TEA::_javascript = $javascript; |
46
|
0
|
|
|
|
|
|
close DATA; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
$je = JE->new; |
49
|
0
|
|
|
|
|
|
$je->eval($javascript); |
50
|
0
|
0
|
|
|
|
|
croak "Webqq::Encryption::TEA load javascript error: $@\n" if $@; |
51
|
0
|
|
|
|
|
|
$Webqq::Encryption::TEA::_je = $je; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
return $je; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
sub encrypt { |
56
|
0
|
|
|
0
|
0
|
|
my ($key,$data) = @_; |
57
|
|
|
|
|
|
|
#$key = join "",map {"\\x$_"} unpack "H2"x length($key),$key; |
58
|
0
|
|
|
|
|
|
my $p = Webqq::Encryption::TEA::Perl::encrypt($key,$data); |
59
|
0
|
0
|
|
|
|
|
return MIME::Base64::encode_base64($p,"") if $p; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#print qq# |
62
|
|
|
|
|
|
|
# var tea = TEA(); |
63
|
|
|
|
|
|
|
# tea.initkey('$key'); |
64
|
|
|
|
|
|
|
# //var r = tea.enWithoutBase64('$data'); |
65
|
|
|
|
|
|
|
# var r = tea.enAsBase64("$data"); |
66
|
|
|
|
|
|
|
# tea.initkey(""); |
67
|
|
|
|
|
|
|
# return(r); |
68
|
|
|
|
|
|
|
##; |
69
|
0
|
|
|
|
|
|
my $je = _load_je(); |
70
|
0
|
|
|
|
|
|
my $p = $je->eval(qq# |
71
|
|
|
|
|
|
|
var tea = TEA(); |
72
|
|
|
|
|
|
|
tea.initkey('$key'); |
73
|
|
|
|
|
|
|
var r = tea.encrypt('$data'); |
74
|
|
|
|
|
|
|
tea.initkey(''); |
75
|
|
|
|
|
|
|
return(r); |
76
|
|
|
|
|
|
|
#); |
77
|
0
|
0
|
0
|
|
|
|
if($p and !$@){ |
78
|
0
|
|
|
|
|
|
return MIME::Base64::encode_base64($p,""); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else{ |
81
|
0
|
|
|
|
|
|
croak "Webqq::Encryption::TEA error: $@\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__DATA__ |