sub server { # my $plaintext = $cipher->decrypt($buf); # my $in = "SERVER: Text: ".$plaintext; # my $ciphertext = $cipher->encrypt($in); # print($new_sock $ciphertext); my $plaintext = decrypt($buf); my $in = "SERVER: Text: ".$plaintext; my $ciphertext = crypt_($in); } sub crypt_ { $cipher->start('encrypting'); print $sock $cipher->crypt($_) while ; print $sock $cipher->finish(); } sub decrypt { $cipher->start('decrypting'); local $/ = \4096; process_bytes($cipher->crypt($_)) while <$sock>; process_bytes($cipher->finish()); }