コード例 #1
0
        private EncryptedTurnover EncryptTurnover()
        {
            var sum                       = TaxData.Sum();
            var counter                   = (Turnover.Value + sum) * 100;
            var registryReceiptId         = RegisterIdentifier.Value + Number.Value;
            var initializationVectorBytes = Encoding.UTF8.GetBytes(registryReceiptId);
            var registryReceiptIdHash     = Sha256(initializationVectorBytes);
            var encryptedValue            = AesCtr(registryReceiptIdHash, (long)counter, Key);

            return(new EncryptedTurnover(encryptedValue));
        }
コード例 #2
0
 public Receipt(
     ReceiptNumber number,
     RegisterIdentifier registerIdentifier,
     TaxData taxData,
     CurrencyValue turnover,
     CertificateSerialNumber certificateSerialNumber,
     JwsRepresentation previousJwsRepresentation,
     byte[] key,
     LocalDateTime created = null)
 {
     Number                    = number ?? throw new ArgumentException("The receipt number has to be specified.");
     RegisterIdentifier        = registerIdentifier ?? throw new ArgumentException("The register identifier has to be specified.");
     TaxData                   = taxData ?? throw new ArgumentException("The tax data have to be specified.");
     Turnover                  = turnover ?? throw new ArgumentException("The turnover has to be specified.");
     CertificateSerialNumber   = certificateSerialNumber ?? throw new ArgumentException("The certificate serial number has to be specified.");
     PreviousJwsRepresentation = previousJwsRepresentation;
     Created                   = created ?? LocalDateTime.Now;
     Suite             = "R1-AT1";
     Key               = key;
     ChainValue        = ComputeChainValue();
     EncryptedTurnover = EncryptTurnover();
 }