Any thoughts or advice?#!/usr/bin/perl -w use strict; use Digest::HMAC_SHA1 qw(hmac_sha1); use MIME::Base64::URLSafe; use MIME::Base64; my $initvectorsize = 16; my $ciphertextsize = 8; my $signaturesize = 4; my $encryptedvaluesize = $initvectorsize + $ciphertextsize + $signatur +esize; my $encryptionkey = 'c488fdd0d81f'; my $integritykey = 'fe3fd7cc8731'; my $plaintext = ''; my $digest = ''; my $initvector = ''; my $ciphertext = ''; my $signature = ''; my $output = ''; print "Enter price to encrypt:"; chomp (my $input = <>); $plaintext = $input; for (my$c=0;$c<$initvectorsize;$c++) { $initvector = $initvector.int(rand(10)); } $digest = hmac_sha1($initvector, $encryptionkey); $ciphertext = $digest ^ $plaintext; $signature = hmac_sha1($plaintext.$initvector, $integritykey); $output = $initvector.substr($ciphertext, 0, $ciphertextsize).substr($ +signature, 0, $signaturesize); print "ERROR: Bad encrypted length!\n" if (length($output) != $encrypt +edvaluesize); $output = urlsafe_b64encode($output); print "ERROR: Bad base64 encoded length!\n" if (length($output) != 38) +; print "Encrypted Price:'$output'\n";
In reply to Private Data Communication Protocol Encryption by pishposh30
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |