login about faq

I want to work with your rsa activex to encrypt credit cards. Example in VB is there you can get me a parallel example in Delphi?

Private Function GetEncryptedCard(ByVal cardNum As String, ByVal CVV As String, ByVal expM As String, ByVal expY As String, ByVal avrZip As String) 'GET PUBLIC KEY

    Dim publicKey_response = dinerware.GetPublicKey()
    Dim publicKey As String = publicKey_response.ToString

'TURN MINIMAL CARD TO XML STRING FOR ENCRYPTION 'VERY IMPORTANT THAT THE XML STRING IS IN THIS ORDER. ANY VARIATION WILL FAIL ON DINERWARE'S END Dim xmlCard = "<card klzzwxh:0000="" 2004="" 07="" dinerware""="" klzzwxh:0001="" 2001="" xmlschema-instance""="">" xmlCard = xmlCard + "<cvv>" + CVV + "</cvv>" xmlCard = xmlCard + "<cardnumber>" + cardNum + "</cardnumber>" xmlCard = xmlCard + "<expmonth>" + expM + "</expmonth>" xmlCard = xmlCard + "<expyear>" + expY + "</expyear>" xmlCard = xmlCard + "<avrzip>" + avrZip + "</avrzip>" xmlCard = xmlCard + "</card>"

'GENERATE KEYS 'CRYPTO STUFF Dim m_cryptoProvider As New TripleDESCryptoServiceProvider

    m_cryptoProvider.GenerateIV()
    m_cryptoProvider.GenerateKey()

    Dim m_key() As Byte = m_cryptoProvider.Key
    Dim m_iv() As Byte = m_cryptoProvider.IV

    Dim theEncryptor As ICryptoTransform
    theEncryptor = m_cryptoProvider.CreateEncryptor(m_key, m_iv)

    Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
    Dim cryptoStream As CryptoStream = _
    New CryptoStream(stream, theEncryptor, _
                          CryptoStreamMode.Write)

    Dim Input() As Byte = System.Text.Encoding.Default.GetBytes(xmlCard)

    cryptoStream.Write(Input, 0, Input.Length)
    cryptoStream.FlushFinalBlock()

    Dim EncryptedCard = System.Convert.ToBase64String(stream.ToArray())

    'make a buffer containing the random IV and Key
    Dim keybuffer(31) As Byte
    Array.Copy(m_key, keybuffer, m_key.Length)
    Array.Copy(m_iv, 0, keybuffer, 24, m_iv.Length)

    'takes byte array
    'returns a base64 encoding of the encrypted string, so it'll be XML-friendly
    'new RSA Provider
    Dim m_RSAcryptoProvider As New RSACryptoServiceProvider(512)
    m_RSAcryptoProvider.FromXmlString(publicKey)

Dim output() As Byte Try output = m_RSAcryptoProvider.Encrypt(keybuffer, False) 'we use false because we can't assume XP or later Catch ex As Exception output = Nothing End Try

Dim encrypted_key_pair = System.Convert.ToBase64String(output)

Dim theEncryptedCard = "<encrypted key="" "="" +encrypted_key_pair+"""="">"+EncryptedCard+"</encrypted>"

Return (theEncryptedCard)

End Function

asked Apr 10 '13 at 08:41

ygalw's gravatar image

ygalw
1111

I Worked by your example and third party identified what I sent him

(Apr 10 '13 at 08:44) ygalw

The xmlcard is the string to Encrypt.

Dim xmlCard = "<card klzzwxh:0000="" 2004="" 07="" dinerware""="" klzzwxh:0001="" 2001="" xmlschema-instance""="">" xmlCard = xmlCard + "<cvv>" + CVV + "</cvv>" xmlCard = xmlCard + "<cardnumber>" + cardNum + "</cardnumber>" xmlCard = xmlCard + "<expmonth>" + expM + "</expmonth>" xmlCard = xmlCard + "<expyear>" + expY + "</expyear>" xmlCard = xmlCard + "<avrzip>" + avrZip + "</avrzip>" xmlCard = xmlCard + "</card>"

(Apr 10 '13 at 08:49) ygalw
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×47

Asked: Apr 10 '13 at 08:41

Seen: 990 times

Last updated: Apr 10 '13 at 08:49

powered by OSQA