Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / bin / tea
CommitLineData
86530b38
AT
1#!/import/bw/tools/local/perl-5.8.0/bin/perl
2
3eval 'exec /import/bw/tools/local/perl-5.8.0/bin/perl -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
5#########################################################################
6# This Perl script is Copyright (c) 2000, Peter J Billam #
7# c/o P J B Computing, www.pjb.com.au #
8# #
9# This program is free software; you can redistribute it and/or #
10# modify it under the same terms as Perl itself. #
11#########################################################################
12use Crypt::Tea;
13
14while ($ARGV[$[] =~ /^-/) {
15 if ($ARGV[$[] =~ /^-c/) { $encrypt='yes'; shift;
16 } elsif ($ARGV[$[] =~ /^-s/) { $sign='yes'; shift;
17 } elsif ($ARGV[$[] =~ /^-j/) { print &tea_in_javascript; exit 1;
18 } else { print <<EOT; exit;
19usage:
20 tea -c filename # encrypts filename
21 tea filename # decrypts filename
22 tea -s filename # calculates ascii digital signature for filename
23 tea -j # outputs JavaScript code to do compatible encryption
24 tea -h # prints this message
25
26For encryption and decryption, you will be asked for a password.
27It should be a sufficiently longish string; say 17 random 8-bit bytes.
28Version 1.43,
29#COMMENT#
30
31EOT
32 }
33}
34# tea -c3 filename # triple-encrypts filename
35# tea -3 filename # triple-decrypts filename
36# for single encryption, or 3 times that to justify triple encryption.
37
38undef $/; my $text = <>; $/="\n";
39if ($sign) { print &asciidigest ($text) . "\n"; exit 0; }
40
41open(TTY, ">/dev/tty") || die "Can't write /dev/tty: $!\n";
42open(TTYIN, "</dev/tty") || die "Can't read /dev/tty: $!\n";
43print TTY 'Password: '; my $key = <TTYIN>;
44close TTY; close TTYIN;
45$key =~ s/[\r\n]*$//;
46exit unless $key;
47
48if ($encrypt) {
49 print &encrypt ($text, $key), "\n";
50} else {
51 print &decrypt ($text, $key);
52}
53exit 0;
54
55__END__
56
57=pod
58
59=head1 NAME
60
61tea - Perl script to give command-line access to Crypt::Tea.pm
62
63=head1 SYNOPSIS
64
65 tea -c filename # encrypts filename
66 tea filename # decrypts filename
67 tea -s filename # calculates ascii digital signature for filename
68 tea -j # outputs JavaScript doing compatible encryption
69 tea -h # prints this message
70
71For encryption and decryption, you will be asked for a password.
72It should be a sufficiently longish string; say 17 random 8-bit bytes.
73
74=head1 DESCRIPTION
75
76This script uses the Crypt::Tea.pm module to offer TEA, the Tiny
77Encryption Algorithm, and some Modes of Use based on CBC, compatibly in
78both Perl and JavaScript.
79
80The various options offer encryption, decryption and digest, and all
81cyphertext is ascii-encoded to prevent munging. Another option returns
82JavaScript code which offers identical functions in JS, and this can
83be used by GCIs to feed to the browser. Triple encryption will be
84offered later.
85
86Version 1.42,
87#COMMENT#
88
89=head1 AUTHOR
90
91Peter J Billam <computing@pjb.com.au>
92
93=head1 CREDITS
94
95Based on Crypt::Tea.pm
96
97=head1 SEE ALSO
98
99http://www.pjb.com.au/, http://www.cpan.org, perl(1).
100
101=cut
102