2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

39_alexa.pm: return empty value if decrypting nothing instead of an error

git-svn-id: https://svn.fhem.de/fhem/trunk@18236 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-01-13 11:41:08 +00:00
parent 8fd5c30f05
commit 438f434ab1

View File

@ -1213,10 +1213,11 @@ alexa_encrypt($)
{
my ($decoded) = @_;
my $key = getUniqueId();
my $encoded;
return "" if( !$decoded );
return $decoded if( $decoded =~ /^crypt:(.*)/ );
my $encoded;
for my $char (split //, $decoded) {
my $encode = chop($key);
$encoded .= sprintf("%.2x",ord($char)^ord($encode));
@ -1230,10 +1231,12 @@ alexa_decrypt($)
{
my ($encoded) = @_;
my $key = getUniqueId();
my $decoded;
return "" if( !$encoded );
$encoded = $1 if( $encoded =~ /^crypt:(.*)/ );
my $decoded;
for my $char (map { pack('C', hex($_)) } ($encoded =~ /(..)/g)) {
my $decode = chop($key);
$decoded .= chr(ord($char)^ord($decode));