"4012",
"VK_VERSION" => "008",
"VK_SND_ID" => "uid100052",
"VK_REC_ID" => "HP",
"VK_NONCE" => "1",
"VK_RETURN" => "http://127.0.0.1:33959/auth/complete/",
"VK_DATETIME" => "2021-02-18T09:17:04+0000",
"VK_ENCODING" => "UTF-8",
);
// STEP 3. Generate data to be signed
// ==================================
// Data to be signed is in the form of XXXYYYYY where XXX is 3 char
// zero padded length of the value and YYY the value itself
// NB! Swedbank expects symbol count, not byte count with UTF-8,
// so use `mb_strlen` instead of `strlen` to detect the length of a string
$data = str_pad (mb_strlen($fields["VK_SERVICE"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_SERVICE"] . /* 4012 */
str_pad (mb_strlen($fields["VK_VERSION"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_VERSION"] . /* 008 */
str_pad (mb_strlen($fields["VK_SND_ID"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_SND_ID"] . /* uid100052 */
str_pad (mb_strlen($fields["VK_REC_ID"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_REC_ID"] . /* HP */
str_pad (mb_strlen($fields["VK_NONCE"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_NONCE"] . /* 1 */
str_pad (mb_strlen($fields["VK_RETURN"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_RETURN"] . /* http://127.0.0.1:33959/auth/complete/ */
str_pad (mb_strlen($fields["VK_DATETIME"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_DATETIME"] . /* 2021-02-18T09:17:04+0000 */
str_pad (mb_strlen($fields["VK_RID"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_RID"]; /* */
/* $data = "0044012003008009uid100052002HP0011037http://127.0.0.1:33959/auth/complete/0242021-02-18T09:17:04+0000000"; */
// STEP 4. Sign the data with RSA-SHA1 to generate MAC code
// ========================================================
openssl_sign ($data, $signature, $private_key, OPENSSL_ALGO_SHA1);
/* p3X29nDEebp3yW3qzS+6bsQYvhDMdLhzmDewCSKRYBHaIVMllVL8RyRrMePn0vZ8QT0cl4JJOfzZNgymnSbuv+q4z9IA9R+HaRxJqURWm6vXnIBZ4/1Ow+erBCf/xgY5Wf9Irhq599koPEYykcHPv+bgoobH8QzVJ7eynhCEW5hC84wH6JxlvMEEYBQ6Mk3kA5Qlta41pESsjIatKD/Gnx3jWDoKM5kb5YF2Y2ygtHfjSIS+UQ4fozOTznMlq0l72parPtfU1Z/tjBnIx4EYlmzJg68fAiZvlnAmx0ZmQQO4hqbDQCSRw5lXcQO8V0bRa8duaqOcbYsKK4IqJDeMjA== */
$fields["VK_MAC"] = base64_encode($signature);
// STEP 5. Generate POST form with payment data that will be sent to the bank
// ==========================================================================
?>
Autentimise näidisrakendus "Swedbank"