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:
justme1968
2019-01-13 11:41:08 +00:00
parent 16fb9b7d36
commit 7b36c319fd

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));