]>
git.zerfleddert.de Git - fhem-stuff/blob - HMLAN/hmlan-crypt-test.pl
cab3ad8b606f407891ac2cf0321719add3a44d19
3 my $key="PUTYOURSECRETHMLANSTICKERKEYHERE";
4 my $hmlan="192.168.1.2";
8 push @INC, dirname
($0);
15 #This should be random...
16 my $my_iv = '00112233445566778899AABBCCDDEEFF';
19 my $sock = IO
::Socket
::INET
->new(
25 my $read_set = new IO
::Select
();
26 $read_set->add($sock);
28 $read_set->can_read();
30 chomp(my $iv = <$sock>);
31 if ($iv =~ /^V(................................)\r$/) {
34 print STDERR
"Unknown IV received: ${iv}\n";
38 print $sock "V${my_iv}\r\n";
40 my $cipher_hmlan=HMLAN_CRYPT
->new(pack("H*", $key), pack("H*", $my_iv));
41 my $cipher_pc=HMLAN_CRYPT
->new(pack("H*", $key), pack("H*", $hmlan_iv));
43 $read_set->add(\
*STDIN
);
46 my @ready = $read_set->can_read();
47 foreach my $r (@ready) {
50 print $cipher_hmlan->decrypt($buf);
56 print $sock $cipher_pc->encrypt($buf);