#!/usr/bin/perl -w use strict; use Crypt::Rijndael; use Crypt::CBC; use Convert::Base64; my $encodedString = 'AI8Xv81IsklU/SLZDV8sW4EqUWKh4yiOm/y0WE5PPmXrciz1NyP3zDzirY1vq0/2wPD0m8ZlTHeGL4Cpygs7/CJAS9pyEz47/Apnn5qix45YpH7m2OXxug/04UyuOFnH'; my @keyArray = (231, 216, 3, 26, 247, 91, 73, 223, 222, 174, 20, 122, 30, 27, 240, 211, 219, 51, 217, 212, 22, 94, 219, 239, 147, 12, 164, 230, 73, 168, 72, 247); my @ivArray = (222, 174, 20, 122, 30, 27, 240, 211, 95, 191, 236, 203, 64, 122, 254, 71); my $key = CreateString(@keyArray); my $initVector = CreateString(@ivArray); my $decryptedString = Encode::decode("UTF-16LE",Decrypt($encodedString, $key, $initVector)); print $decryptedString; sub Decrypt { my $encodedString = shift; my $key = shift; my $initVector = shift; #1. Schritt #Das Array mit den korrekten Daten #my @cipherData =(0, 143, 23, 191, 205, 72, 178, 73, 84, 253, 34, 217, 13, 95, 44, 91, 129, 42, 81, 98, 161, 227, 40, 142, 155, 252, 180, 88, 78, 79, 62, 101, 235, 114, 44, 245, 55, 35, 247, 204, 60, 226, 173, 141, 111, 171, 79, 246, 192, 240, 244, 155, 198, 101, 76, 119, 134, 47, 128, 169, 202, 11, 59, 252, 34, 64, 75, 218, 114, 19, 62, 59, 252, 10, 103, 159, 154, 162, 199, 142, 88, 164, 126, 230, 216, 229, 241, 186, 15, 244, 225, 76, 174, 56, 89, 199); my @cipherData = DecodeBase64ToArray($encodedString); #2. Schritt my @decryptedData = (); #Das Array mit den korrekten Daten #@decryptedData = (80, 0, 101, 0, 114, 0, 108, 0, 32, 0, 117, 0, 110, 0, 100, 0, 32, 0, 67, 0, 35, 0, 32, 0, 115, 0, 105, 0, 110, 0, 100, 0, 32, 0, 99, 0, 111, 0, 111, 0, 108, 0, 101, 0, 32, 0, 80, 0, 114, 0, 111, 0, 103, 0, 114, 0, 97, 0, 109, 0, 109, 0, 105, 0, 101, 0, 114, 0, 115, 0, 112, 0, 114, 0, 97, 0, 99, 0, 104, 0, 101, 0, 110, 0, 33, 0); #Hier mit string als Test my $base64String = DecodeBase64ToString($encodedString); my $cipher = Crypt::CBC->new( { key => $key, #The encryption/decryption key (required) cipher => 'Rijndael', #The cipher algorithm (defaults to Crypt::DES), or a preexisting cipher object. iv => $initVector, #The initialization vector (IV) header => 'none', #What type of header to prepend to ciphertext. One of 'salt' -- use OpenSSL-compatible salted header 'randomiv' -- Randomiv-compatible "RandomIV" header 'none' -- prepend no header at all padding => 'standard', #The padding method, one of "standard" (default), "space", "oneandzeroes", "rijndael_compat", "null", or "none" (default "standard"). literal_key => 0, #If true, the key provided by "key" is used directly for encryption/decryption. Otherwise the actual key used will be a hash of the provided key. (default false) pcbc => 0, #Whether to use the PCBC chaining algorithm rather than the standard CBC algorithm (default false) keysize => 32, #Force the cipher keysize to the indicated number of bytes. blocksize => 16 #Force the cipher blocksize to the indicated number of bytes. } ); foreach my $value (@cipherData) { push(@decryptedData, $cipher->decrypt($value)); } #Hier mit string als Test my $decodedString = $cipher->decrypt($base64String); #3. Schritt my $unicodeString = ConvertToUnicode(@decryptedData); return $unicodeString; } sub ConvertToUnicode { my @byteArray = @_; return join('', map chr, @byteArray); } sub DecodeBase64ToArray { my $encodedString = shift; my @base64decoded = (); my $base64string = unpack("H*",decode_base64($encodedString)); my @base64HexDecoded = $base64string =~ /\w{2}/g; @base64decoded = ConvertToDecimal(@base64HexDecoded); return @base64decoded; } sub DecodeBase64ToString { my $encodedString = shift; return decode_base64($encodedString); } sub ConvertToDecimal { my @hexArray = @_; my @returnArray = (); foreach my $hexValue (@hexArray) { push(@returnArray, hex($hexValue)); } return @returnArray; } sub CreateString { my @array = @_; my @chars = (); foreach my $value (@array) { push(@chars, chr($value)); } return join('', @chars); }