← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Crypt/RC4.pm
StatementsExecuted 10 statements in 298µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1119µs11µsCrypt::RC4::::BEGIN@15Crypt::RC4::BEGIN@15
1113µs27µsCrypt::RC4::::BEGIN@16Crypt::RC4::BEGIN@16
0000s0sCrypt::RC4::::RC4Crypt::RC4::RC4
0000s0sCrypt::RC4::::SetupCrypt::RC4::Setup
0000s0sCrypt::RC4::::newCrypt::RC4::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#--------------------------------------------------------------------#
2# Crypt::RC4
3# Date Written: 07-Jun-2000 04:15:55 PM
4# Last Modified: 13-Dec-2001 03:33:49 PM
5# Author: Kurt Kincaid (sifukurt@yahoo.com)
6# Copyright (c) 2001, Kurt Kincaid
7# All Rights Reserved.
8#
9# This is free software and may be modified and/or
10# redistributed under the same terms as Perl itself.
11#--------------------------------------------------------------------#
12
13package Crypt::RC4;
14
15220µs212µs
# spent 11µs (9+1) within Crypt::RC4::BEGIN@15 which was called: # once (9µs+1µs) by Spreadsheet::ParseExcel::BEGIN@26 at line 15
use strict;
# spent 11µs making 1 call to Crypt::RC4::BEGIN@15 # spent 1µs making 1 call to strict::import
162269µs251µs
# spent 27µs (3+24) within Crypt::RC4::BEGIN@16 which was called: # once (3µs+24µs) by Spreadsheet::ParseExcel::BEGIN@26 at line 16
use vars qw( $VERSION @ISA @EXPORT $MAX_CHUNK_SIZE );
# spent 27µs making 1 call to Crypt::RC4::BEGIN@16 # spent 24µs making 1 call to vars::import
17
181300ns$MAX_CHUNK_SIZE = 1024 unless $MAX_CHUNK_SIZE;
19
201300nsrequire Exporter;
21
2215µs@ISA = qw(Exporter);
231300ns@EXPORT = qw(RC4);
241100ns$VERSION = '2.02';
25
26sub new {
27 my ( $class, $key ) = @_;
28 my $self = bless {}, $class;
29 $self->{state} = Setup( $key );
30 $self->{x} = 0;
31 $self->{y} = 0;
32 $self;
33}
34
35sub RC4 {
36 my $self;
37 my( @state, $x, $y );
38 if ( ref $_[0] ) {
39 $self = shift;
40 @state = @{ $self->{state} };
41 $x = $self->{x};
42 $y = $self->{y};
43 } else {
44 @state = Setup( shift );
45 $x = $y = 0;
46 }
47 my $message = shift;
48 my $num_pieces = do {
49 my $num = length($message) / $MAX_CHUNK_SIZE;
50 my $int = int $num;
51 $int == $num ? $int : $int+1;
52 };
53 for my $piece ( 0..$num_pieces - 1 ) {
54 my @message = unpack "C*", substr($message, $piece * $MAX_CHUNK_SIZE, $MAX_CHUNK_SIZE);
55 for ( @message ) {
56 $x = 0 if ++$x > 255;
57 $y -= 256 if ($y += $state[$x]) > 255;
58 @state[$x, $y] = @state[$y, $x];
59 $_ ^= $state[( $state[$x] + $state[$y] ) % 256];
60 }
61 substr($message, $piece * $MAX_CHUNK_SIZE, $MAX_CHUNK_SIZE) = pack "C*", @message;
62 }
63 if ($self) {
64 $self->{state} = \@state;
65 $self->{x} = $x;
66 $self->{y} = $y;
67 }
68 $message;
69}
70
71sub Setup {
72 my @k = unpack( 'C*', shift );
73 my @state = 0..255;
74 my $y = 0;
75 for my $x (0..255) {
76 $y = ( $k[$x % @k] + $state[$x] + $y ) % 256;
77 @state[$x, $y] = @state[$y, $x];
78 }
79 wantarray ? @state : \@state;
80}
81
82
8313µs1;
84__END__