my $user_string = "VendorTxCode=1298062774&Amount=43.01&Currency=GBP&Description=Goods&SuccessURL=http://www.happy.com/success.html&FailureURL=http://www.unhappy.com/failure.html&BillingSurname=Bloggs&BillingFirstnames=Fred&BillingAddress1=30 Peyton Place&BillingCity=Somewhere&BillingPostCode=AB1 2CD&BillingCountry=UK&DeliverySurname=Bloggs&DeliveryFirstnames=Bill&DeliveryAddress1=30 Peyton Place&DeliveryCity=Somewhere&DeliveryPostCode=AB1 2CD&DeliveryCountry=UK"; my $key = "TuDQUBZVA4kPfeM7"; my $size = length($user_string); my $encode = $key x $size; my $portion = substr($encode, 0, $size); my $result = $user_string ^ $portion; my $base_encoded = encode_base64($result,''); my $base_key = encode_base64($key,'');