为银行交易生成唯一密钥

Generate a Unique Key for Banking Transactions

我想通过 HBCI 持续导入银行交易。 问题是,那些既没有唯一密钥,也没有确切的时间戳(时间戳仅在日分辨率上,即总是上午 12 点)。

这是我从 API

获得的数据

在所有字段上生成散列会导致误报(如果有人在同一天使用相同目的的文本传输相同的值等等)

如何避免重复导入并生成唯一密钥?

/**
 * Generate a unique ID per transaction
 * We assume, that all transactions of a day are always present in the fetched transactions
 * (after a while, very old transactions might not appear)
 * So we generate a continues key per day, combine it with the date and have a globally unique key
 *
 * @return Transaction[]
 */
public static function getKeyedTransactions()
{
    $transactions = self::getTransactions();
    $result = [];
    $dateCounters = array();
    foreach($transactions as $transaction) {
        $date = $transaction->getDate()->format('Ymd');
        if (!isset($dateCounters[$date])) {
            $dateCounters[$date] = 0;
        }
        $dateCounters[$date]++;
        $uniqId = $date . sprintf('%05d', $dateCounters[$date]);
        $result[$uniqId] = $transaction;
    }
    return $result;
}