1

I want to apply AES 128 bit algorithm for 16 digit credit card numbers. How can I convert 16 digit credit card number to 128 bit AES plain text? Here is what I'm doing:

  1. Apply ASCII hex value for each digit
  2. Each hex value is converted to 4 bit binary number
  3. For each decimal digit there are 8 bit bits

Is it correct method?

2
  • 1
    Is what (the) correct method? You've mentioned something I couldn't quite follow about how you'd convert digits but nothing to do with encrypting anything. Commented Mar 17, 2014 at 13:14
  • Are you wanting to encrypt them to store them in a database? Commented Mar 17, 2014 at 13:23

1 Answer 1

0

When it comes to encrypting credit cards numbers (or any string of fixed length) my recommendation would be to use Format-Preserving Encryption. As the name implies, the goal of a Format-Preserving Encryption scheme is to securely encrypt while preserving the original formatting of the plaintext data. In a nutshell, a 16-digit cc number can encrypt to a 16-digit number, so the encrypted length is the same.

In contrast, encrypting using AES-128 in ECB mode the resulting ciphertext will be 64 bits. Another disadvantage is that identical plaintext blocks are encrypted into identical ciphertext blocks; thus it does not hide patterns well.

It's hard to give examples of implementation since your environment and intent were not included in the question but again, if you are wanting to encrypt cc numbers which can then be used as plaintext, Format-Preserving Encryption is your best bet.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.