API.pm

filter: Statementstmt 87.5% 217 / 248 Branchbran 60.0% 18 / 30 Conditioncond 66.6% 6 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 74.7% 74 / 99 Podpod 9.2% 5 / 54 totaltotal 71.9% 321 / 446 CC 20 SCAR 7.3
CC
20
Cov
84%
send
7.1
alphanum_to_digit
6.0
digit_to_alphanum
6.0
CRAP 2.1
« API/Request/Contacts.pm ↑ Summary API/Request/AdUpdate.pm »
1 package Finance::LocalBitcoins::API;
2  
3 1 ▶use 5.014002;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.01';
8  
9 1 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use constant VERBOSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # you can use a lower version, but then you are responsible for SSL cert verification code...
13 1 ▶use LWP::UserAgent 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 ## PUBLIC requests..
19 1 ▶use Finance::LocalBitcoins::API::Request::Ticker;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Finance::LocalBitcoins::API::Request::TradeBook;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Finance::LocalBitcoins::API::Request::OrderBook;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # PRIVATE requests..
24 1 ▶use Finance::LocalBitcoins::API::Request::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Finance::LocalBitcoins::API::Request::Me;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Finance::LocalBitcoins::API::Request::Pin;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Finance::LocalBitcoins::API::Request::Dash;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Finance::LocalBitcoins::API::Request::Wallet;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use Finance::LocalBitcoins::API::Request::Balance;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use Finance::LocalBitcoins::API::Request::ReleaseEscrow;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use Finance::LocalBitcoins::API::Request::Paid;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use Finance::LocalBitcoins::API::Request::Messages;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use Finance::LocalBitcoins::API::Request::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use Finance::LocalBitcoins::API::Request::Dispute;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use Finance::LocalBitcoins::API::Request::Cancel;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use Finance::LocalBitcoins::API::Request::Fund;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use Finance::LocalBitcoins::API::Request::NewContact;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use Finance::LocalBitcoins::API::Request::Contact;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use Finance::LocalBitcoins::API::Request::Contacts;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 1 ▶use Finance::LocalBitcoins::API::Request::Send;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 1 ▶use Finance::LocalBitcoins::API::Request::SendPin;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use Finance::LocalBitcoins::API::Request::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use Finance::LocalBitcoins::API::Request::Logout;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use Finance::LocalBitcoins::API::Request::Ads;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 1 ▶use Finance::LocalBitcoins::API::Request::AdGet;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use Finance::LocalBitcoins::API::Request::AdsGet;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 ▶use Finance::LocalBitcoins::API::Request::AdUpdate;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use Finance::LocalBitcoins::API::Request::Ad;
Subroutine BEGIN: called CC=1 SCAR=0.0
49
50 1 ▶use constant COMPANY => 'LocalBitcoins';
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶use constant ERROR_NO_REQUEST => 'No request object to send';
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 ▶use constant ERROR_NOT_READY => 'Not enough information to send a %s request';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use constant ERROR_IS_IT_READY => "The request is%s READY to send\n";
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use constant ERROR_RESPONSE => COMPANY . ' error';
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 ▶use constant ERROR_UNKNOWN_STATUS => COMPANY . " returned an unknown status\n";
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 1 ▶use constant ATTRIBUTES => qw(token);
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 1 ▶use constant CLASS_ACTION_MAP => {
Subroutine BEGIN: called CC=1 SCAR=0.0
60 user => 'Finance::LocalBitcoins::API::Request::User',
61 me => 'Finance::LocalBitcoins::API::Request::Me',
62 pin => 'Finance::LocalBitcoins::API::Request::Pin',
63 dash => 'Finance::LocalBitcoins::API::Request::Dash',
64 release_escrow => 'Finance::LocalBitcoins::API::Request::ReleaseEscrow',
65 paid => 'Finance::LocalBitcoins::API::Request::Paid',
66 messages => 'Finance::LocalBitcoins::API::Request::Messages',
67 message => 'Finance::LocalBitcoins::API::Request::Message',
68 dispute => 'Finance::LocalBitcoins::API::Request::Dispute',
69 cancel => 'Finance::LocalBitcoins::API::Request::Cancel',
70 fund => 'Finance::LocalBitcoins::API::Request::Fund',
71 new_contact => 'Finance::LocalBitcoins::API::Request::NewContact',
72 contact => 'Finance::LocalBitcoins::API::Request::Contact',
73 contacts => 'Finance::LocalBitcoins::API::Request::Contacts',
74 wallet => 'Finance::LocalBitcoins::API::Request::Wallet',
75 balance => 'Finance::LocalBitcoins::API::Request::Balance',
76 'send' => 'Finance::LocalBitcoins::API::Request::Send',
77 sendpin => 'Finance::LocalBitcoins::API::Request::SendPin',
78 address => 'Finance::LocalBitcoins::API::Request::Address',
79 logout => 'Finance::LocalBitcoins::API::Request::Logout',
80 ads => 'Finance::LocalBitcoins::API::Request::Ads',
81 ad_get => 'Finance::LocalBitcoins::API::Request::AdGet',
82 ads_get => 'Finance::LocalBitcoins::API::Request::AdsGet',
83 ad_update => 'Finance::LocalBitcoins::API::Request::AdUpdate',
84 ad => 'Finance::LocalBitcoins::API::Request::Ad',
85 ticker => 'Finance::LocalBitcoins::API::Request::Ticker',
86 tradebook => 'Finance::LocalBitcoins::API::Request::TradeBook',
87 orderbook => 'Finance::LocalBitcoins::API::Request::OrderBook',
88 1 };
89  
90 10 ▶sub is_ready_to_send {
Subroutine is_ready_to_send: called CC=3 SCAR=11.2
Pod undocumented
91 10 my $self = shift;
92 10 my $ready = 0;
93 # here we are checking whether or not to default to '0' (not ready to send) based on this objects settings.
94 # the setting in here is the token provided to you by LocalBitcoins.
95 # if we dont have to add a token, then just check if its ready...
96 10 ▶ if (not $self->private or defined $self->token) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->private or defined $self->token) 10 0 10
Condition66%2/3
not $self->private or defined $self->token
l!l&&r!l&&!r
370
MC/DC0%0/2
not $self->private or defined $self->token
not $self->private defined $self->token
Truth table66%2/3
not(A) or B
A= not $self->privateB= defined $self->token
ABresult
1X1
011
000
97 10 $ready = $self->request->is_ready_to_send;
98 }
99 10 warn sprintf ERROR_IS_IT_READY, ($ready ? '' : ' NOT') if DEBUG;
100  
101 10 return $ready;
102 }
103  
104 10 ▶sub send {
Subroutine send: called CC=7 SCAR=19.6
Pod undocumented
105 10 my $self = shift;
106  
107 # clear any previous response values... because if you wan it, you shoulda put a variable on it.
108 10 $self->response(undef);
109 10 $self->error(undef);
110  
111 10 ▶ unless ($self->request) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->request) { } 10 0 10
112 0 $self->error({
113 type => __PACKAGE__,
114 message => ERROR_NO_REQUEST,
115 });
116 }
117 else {
118 # validate that the minimum required request attributes are set here.
119 10 ▶ if (not $self->is_ready_to_send) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->is_ready_to_send) { } 0 10 10
120 0 $self->error({
121 type => __PACKAGE__,
122 message => sprintf(ERROR_NOT_READY, ref $self->request),
123 });
124 }
125 else {
126 # make sure we have an request to send...
127 10 my $request = $self->http_request(HTTP::Request->new);
128 10 $request->method($self->request->request_type);
129 10 $request->uri($self->request->url);
130 10 my %query_form = %{$self->request_content};
131 #
132 # This block will be removed once we have basic testing completed.
133 # ...because printing these variables on a live system is not a good idea...
134 #
135 #if ($self->private) {
136 # print Data::Dumper->Dump([\%query_form],['Query Form']);
137 # printf "Token: %s\n", $self->token;
138 # printf "Path: %s\n", $self->path;
139 #}
140 #
141 10 ▶ if ($self->private) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->private) 7 3 10
142 7 $query_form{access_token} = $self->token;
143 }
144  
145 10 my $uri = URI->new;
146 10 $uri->query_form(%query_form);
147 10 ▶ if ($self->request->request_type eq 'POST') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->request->request_type eq 'POST') { } 6 4 10
elsif ($self->request->request_type eq 'GET' and $uri->query) { } 2 2 4
148 6 $request->content($uri->query);
149 6 $request->content_type($self->request->content_type);
150 }
151 ▶ elsif ($self->request->request_type eq 'GET' and $uri->query) {
Condition66%2/3
$self->request->request_type eq "GET" and $uri->query
!ll&&!rl&&r
022
MC/DC50%1/2
$self->request->request_type eq "GET" and $uri->query
$self->request->request_type eq "GET" $uri->query
Truth table66%2/3
A and B
A= $self->request->request_type eq "GET"B= $uri->query
ABresult
0X0
100
111
152 2 $request->uri($request->uri . '?' . $uri->query);
153 }
154
155 10 $request->header(Accept => 'application/json');
156  
157 # create a new user_agent each time...
158 10 $self->user_agent(LWP::UserAgent->new);
159 10 $self->user_agent->agent('Mozilla/8.0');
160 10 $self->user_agent->ssl_opts(verify_hostname => 1);
161  
162 10 warn Data::Dumper->Dump([$self->user_agent, $request],[qw(UserAgent Request)]) if DEBUG;
163  
164 10 $self->http_response($self->user_agent->request($request));
165 10 $self->process_response;
166 }
167 }
168 10 return $self->is_success;
169 }
170  
171 10 ▶sub process_response {
Subroutine process_response: called CC=5 SCAR=17.6
Pod undocumented
172 10 my $self = shift;
173  
174 10 warn sprintf "Content: %s\n", $self->http_response->content if DEBUG;
175  
176 eval {
177 10 my $content;
178 10 warn Data::Dumper->Dump([$self->http_response],['Response']) if DEBUG;
179 10 $content = $self->json->decode($self->http_response->content);
180 7 ▶ if (ref $content eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $content eq 'ARRAY') { } 0 7 7
elsif (exists $content->{'error'}) { } 7 0 7
elsif ($self->http_response->code != 200) { } 0 0 0
181 0 $self->response($content);
182 }
183 elsif (exists $content->{error}) {
184 $self->error({
185 type => ERROR_RESPONSE,
186 7 %{$content->{error}},
187 });
188 }
189 elsif ($self->http_response->code != 200) {
190 0 warn sprintf "Invalid Server Response Code: %s\n", $self->http_response->code if VERBOSE;
191 0 $self->error({
192 type => 'Server Response Error',
193 message => sprintf('%s Server Response: %s', COMPANY, $self->http_response->code),
194 });
195 }
196 else {
197 0 $self->response($content);
198 }
199 7 1;
200 10 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { my $content; '???'; $content = $self->json->decode($self->http_response->content); if (ref $content eq "ARRAY") { $self->response($content); } elsif (exists $content->{"error"}) { $self->error({"type", "LocalBitcoins error", %{$content->{"error"};}}); } elsif ($self->http_response->code != 200) { '???'; $self->error({"type", "Server Response Error", "message", sprintf("%s Server Response: %s", "LocalBitcoins", $self->http_response->code)}); } else { $self->response($content); } ; 1 } } or do { warn "eval error: $@\n"; $self->error({"type", "eval/json error", "message", $@}) } 7 3 10
201 3 warn "eval error: $@\n";
202 3 $self->error({
203 type => 'eval/json error',
204 message => $@,
205 });
206 };
207  
208 10 return $self->is_success;
209 }
210  
211 2 ▶sub new { (bless {} => shift)->init(@_) }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
212 0 ▶sub path { URI->new(shift->http_request->uri)->path }
Subroutine path: not called CC=1 SCAR=6.9
Pod undocumented
213 10 ▶sub request_content { shift->request->request_content }
Subroutine request_content: called CC=1 SCAR=0.0
Pod undocumented
214 10 ▶sub json { shift->{json} ||= JSON->new }
Subroutine json: called CC=2 SCAR=7.2
Pod undocumented
Condition66%2/3
+(shift())->{"json"} ||= "JSON"->new
l!l&&r!l&&!r
820
MC/DC0%0/2
+(shift())->{"json"} ||= "JSON"->new
+(shift())->{"json"} "JSON"->new
Truth table66%2/3
A ||= B
A= +(shift())->{"json"}B= "JSON"->new
ABresult
1X1
011
000
215 20 ▶sub is_success { defined shift->response }
Subroutine is_success: called CC=1 SCAR=0.0
Pod undocumented
216 20 ▶sub private { shift->request->is_private }
Subroutine private: called CC=1 SCAR=0.0
Pod undocumented
217 0 ▶sub public { not shift->private }
Subroutine public: not called CC=1 SCAR=6.9
Pod undocumented
218 2 ▶sub attributes { ATTRIBUTES }
Subroutine attributes: called CC=1 SCAR=0.0
Pod undocumented
219  
220 1 ▶sub user { class_action(@_) }
Subroutine user: called CC=1 SCAR=0.0
Pod undocumented
221 1 ▶sub me { class_action(@_) }
Subroutine me: called CC=1 SCAR=0.0
Pod undocumented
222 1 ▶sub pin { class_action(@_) }
Subroutine pin: called CC=1 SCAR=0.0
Pod undocumented
223 1 ▶sub dash { class_action(@_) }
Subroutine dash: called CC=1 SCAR=0.0
Pod undocumented
224 0 ▶sub release_escrow { class_action(@_) }
Subroutine release_escrow: not called CC=1 SCAR=6.9
Pod undocumented
225 0 ▶sub paid { class_action(@_) }
Subroutine paid: not called CC=1 SCAR=6.9
Pod undocumented
226 0 ▶sub messages { class_action(@_) }
Subroutine messages: not called CC=1 SCAR=6.9
Pod undocumented
227 0 ▶sub message { class_action(@_) }
Subroutine message: not called CC=1 SCAR=6.9
Pod undocumented
228 0 ▶sub dispute { class_action(@_) }
Subroutine dispute: not called CC=1 SCAR=6.9
Pod undocumented
229 0 ▶sub cancel { class_action(@_) }
Subroutine cancel: not called CC=1 SCAR=6.9
Pod undocumented
230 0 ▶sub fund { class_action(@_) }
Subroutine fund: not called CC=1 SCAR=6.9
Pod undocumented
231 0 ▶sub new_contact { class_action(@_) }
Subroutine new_contact: not called CC=1 SCAR=6.9
Pod undocumented
232 0 ▶sub contact { class_action(@_) }
Subroutine contact: not called CC=1 SCAR=6.9
Pod undocumented
233 0 ▶sub contacts { class_action(@_) }
Subroutine contacts: not called CC=1 SCAR=6.9
Pod undocumented
234 1 ▶sub wallet { class_action(@_) }
Subroutine wallet: called CC=1 SCAR=0.0
Pod undocumented
235 1 ▶sub balance { class_action(@_) }
Subroutine balance: called CC=1 SCAR=0.0
Pod undocumented
236 0 ▶sub send_coin { class_action(@_) }
Subroutine send_coin: not called CC=1 SCAR=6.9
Pod undocumented
237 0 ▶sub send_pin { class_action(@_) }
Subroutine send_pin: not called CC=1 SCAR=6.9
Pod undocumented
238 0 ▶sub address { class_action(@_) }
Subroutine address: not called CC=1 SCAR=6.9
Pod undocumented
239 0 ▶sub logout { class_action(@_) }
Subroutine logout: not called CC=1 SCAR=6.9
Pod undocumented
240 1 ▶sub ads { class_action(@_) }
Subroutine ads: called CC=1 SCAR=0.0
Pod undocumented
241 0 ▶sub ad_get { class_action(@_) }
Subroutine ad_get: not called CC=1 SCAR=6.9
Pod undocumented
242 0 ▶sub ads_get { class_action(@_) }
Subroutine ads_get: not called CC=1 SCAR=6.9
Pod undocumented
243 0 ▶sub ad_update { class_action(@_) }
Subroutine ad_update: not called CC=1 SCAR=6.9
Pod undocumented
244 0 ▶sub ad { class_action(@_) }
Subroutine ad: not called CC=1 SCAR=6.9
Pod undocumented
245 1 ▶sub ticker { class_action(@_) }
Subroutine ticker: called CC=1 SCAR=0.0
Pod undocumented
246 1 ▶sub tradebook { class_action(@_) }
Subroutine tradebook: called CC=1 SCAR=0.0
Pod undocumented
247 1 ▶sub orderbook { class_action(@_) }
Subroutine orderbook: called CC=1 SCAR=0.0
Pod undocumented
248  
249 15 ▶sub token { get_set(@_) }
Subroutine token: called CC=1 SCAR=0.0
Pod documented
250 30 ▶sub error { get_set(@_) }
Subroutine error: called CC=1 SCAR=0.0
Pod documented
251 20 ▶sub http_response { get_set(@_) }
Subroutine http_response: called CC=1 SCAR=0.0
Pod undocumented
252 100 ▶sub request { get_set(@_) }
Subroutine request: called CC=1 SCAR=0.0
Pod documented
253 30 ▶sub response { get_set(@_) }
Subroutine response: called CC=1 SCAR=0.0
Pod undocumented
254 10 ▶sub http_request { get_set(@_) }
Subroutine http_request: called CC=1 SCAR=0.0
Pod undocumented
255 40 ▶sub user_agent { get_set(@_) }
Subroutine user_agent: called CC=1 SCAR=0.0
Pod documented
256  
257 2 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
258 2 my $self = shift;
259 2 my %args = @_;
260 2 foreach my $attribute ($self->attributes) {
261 2 ▶ $self->$attribute($args{$attribute}) if exists $args{$attribute};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$attribute} 1 1 2
262 }
263 2 return $self;
264 }
265  
266 # this method simply makes all the get/setter attribute methods below very tidy...
267 245 ▶sub get_set {
Subroutine get_set: called CC=2 SCAR=6.9
Pod undocumented
268 245 my $self = shift;
269 245 my $attribute = ((caller(1))[3] =~ /::(\w+)$/)[0];
270 245 ▶ $self->{$attribute} = shift if scalar @_;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ 71 174 245
271 245 return $self->{$attribute};
272 }
273  
274 10 ▶sub class_action {
Subroutine class_action: called CC=2 SCAR=7.0
Pod undocumented
275 10 my $self = shift;
276 10 my $class = CLASS_ACTION_MAP->{((caller(1))[3] =~ /::(\w+)$/)[0]};
277 10 $self->request($class->new(@_));
278 10 ▶ return $self->send ? $self->response : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->send ? : 0 10 10
279 }
280  
281 # These additional routines will allow you to easily encrypt your API secret using a similar but random text string as a key.
282 # Generate and store a random string of 40 hex chars in your script.
283 # perl -e 'use Finance::CaVirtex::API qw(string_encrypt); print "Encrypted: %s\n", string_encrypt('put your token here', $random_key);
284 # to output the cyphertext of the real secret encrypted using your key.
285 # Your script should then load the cyphertext from an external file and call this:
286 # my $api_secret = string_decrypt($cyphertext, $random_key);
287 # Since both the random_key and the cyphertext are in separate files, a breach would require both files to be compromised.
288 # If you also put the token into a database table that is accessed during runtime... then you are further protected.
289 # This setup would require 3 distinct components which would all need to be compromised to gain unwanted access to your API keys and functions.
290 #
291 # From the command line, you can generate a set of semi-random strings that should be good enough for this using:
292 # perl -e 'print join("",("a".."z",0..9)[map rand$_,(36) x 22])."\n"for 1..20;'
293 #
294 # select one of those as your random_key.
295 #
296  
297 # encryption works by assigning an ordinal value to each character '0' = 0 ... 'Z' = 35
298 # these values are then added for each character in the cypher and the random key.
299 # the modulus of the sum is then taken to remain within the 36 available characters.
300 # this number is then converted back to character.
301 # once each character of the string is calculated, the complete cyphertext is generated.
302 #
303 # the end result is that we are adding the secret string to the random key string to obtain the cyphertext:
304 # Cypher = Secret + Key
305 #
306 # decryption is exactly like encryption except we take the difference of each character
307 # instead of the sum.
308 #
309 # the end result is thatIn this way we are subtracting the random key from the cyphertext to get back the secret string.
310 # Secret = Cypher - Key
311 #
312 # I believe this method is equivalent to XOR encryption, which is very strong as long as the key is random and kept secret.
313 #
314 0 ▶sub alphanum_to_digit { ord($_[0]) > 57 ? ord($_[0]) - 87 : ord($_[0]) - 48 }
Subroutine alphanum_to_digit: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ord $_[0] > 57 ? : 0 0 0
315 0 ▶sub digit_to_alphanum { chr($_[0] > 9 ? $_[0] + 87 : $_[0] + 48) }
Subroutine digit_to_alphanum: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0] > 9 ? : 0 0 0
316 0 ▶sub string_encrypt { join '', map(digit_to_alphanum((alphanum_to_digit(substr $_[0], $_, 1) + alphanum_to_digit(substr $_[1], $_, 1)) % 36), 0 .. length($_[0]) - 1) }
Subroutine string_encrypt: not called CC=1 SCAR=6.9
Pod undocumented
317 0 ▶sub string_decrypt { join '', map(digit_to_alphanum((alphanum_to_digit(substr $_[0], $_, 1) - alphanum_to_digit(substr $_[1], $_, 1)) % 36), 0 .. length($_[0]) - 1) }
Subroutine string_decrypt: not called CC=1 SCAR=6.9
Pod undocumented
318 0 ▶sub gen_random_key { join("",("a".."f",0..9)[map rand$_,(16) x 40]) }
Subroutine gen_random_key: not called CC=1 SCAR=6.9
Pod undocumented
319  
320  
321 1 1;
322  
323 __END__
« API/Request/Contacts.pm ↑ Summary API/Request/AdUpdate.pm »