0

The QR code fields shall be encoded in Tag-Length-Value (TLV) format with the tag values specified in the “Tag” column of the adjacent table.

The TLV encoding shall be as follows:

Tag: the tag value as mentioned above stored in one byte. Length: the length of the byte array resulted from the UTF8 encoding of the field value. The length shall be stored in one byte. Value: the byte array resulting from the UTF8 encoding of the field value.

Looking for Asp.net/Vb.net

Thanks in Advance

Ather
  • 11
  • 1
  • 1
    What have you tried? Add the code to your question, pointing our where it goes wrong. Error message? etc. Take the [tour]. – Mary Nov 24 '21 at 08:22
  • I don't know where to start, I found some posts about the same but it was in PHP by @Salla ( https://github.com/SallaApp/ZATCA ), looking similar library for vb.net – Ather Nov 24 '21 at 08:36
  • Most libraries made for .Net are usable in vb.net. Google "TLV in .net". I got many results. – Mary Nov 24 '21 at 08:44
  • Yes i did it, found 2, one for PHP and other one for JAVA. Actually this is related to ZATCA, New e-Invoicing Project in KSA. Still googling and posted here if someone else found something. – Ather Nov 24 '21 at 08:48
  • Questions that seek software libraries are off-topic on this site. – Peter O. Nov 24 '21 at 08:57
  • Refer to this post, the same i am looking but in .Net https://stackoverflow.com/questions/69530804/how-to-create-and-parse-tag-length-value-tlv-in-php-and-encode-it-in-base64 – Ather Nov 24 '21 at 09:00
  • Have you tried to search the word `ZATCA` in GitHub? – Bu Saeed Nov 24 '21 at 13:02
  • I tired, found your code for PHP – Ather Nov 24 '21 at 13:16
  • https://github.com/aljbri/Zatca.Net & https://github.com/alquhait/ZatcaDotNetCore & https://github.com/GeeSuth/GeeSuthSoft.KSA.ZATCA – Bu Saeed Nov 24 '21 at 15:40

1 Answers1

3

I was able to successfully create the TLV encoding in vb.net and it passed Zatca validation. I created a very simple form with 5 inputs: enter image description here

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        Dim value1 As String = getTLV(1, TextBox1.Text)
        Dim value2 As String = getTLV(2, TextBox2.Text)
        Dim value3 As String = getTLV(3, TextBox3.Text)
        Dim value4 As String = getTLV(4, TextBox4.Text)
        Dim value5 As String = getTLV(5, TextBox5.Text)
        Dim b As Byte() = System.Text.Encoding.UTF8.GetBytes(value1 & value2 & value3 & value4 & value5)
        Dim t As String = Convert.ToBase64String(b)
        TextBox6.Text = t
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

Private Function getTLV(tag As Integer, value As String) As String
    Return Chr(tag) & Chr(value.Length) & value
End Function