0

I have a number like this "3344550043374314" and I need an algorithm that can cypher this number and then add it to a VARCHAR column in a database.

  1. The encrypted number must not exceed the DB COLUMN size (19)
  2. Database column type cannot be altered

I've tested with "one time pad", "CaesarCipher", "DES", "secure HASH". None of them worked as a solution to this.

I need and encrypt/decrypt function that receives a key and string.

João Mendes
  • 1,611
  • 16
  • 29
Reversed
  • 51
  • 1
  • 10
  • you have to alter the DB size or else have to create your own cypher – TaherT Dec 02 '13 at 11:31
  • Will this numbers be negative any time and what is maximum number of digit a value can have that you want to store – dbw Dec 02 '13 at 11:31
  • 1
    To assist in your research, this is typically known as [**format-preserving encryption**](http://blog.cryptographyengineering.com/2011/11/format-preserving-encryption-or-how-to.html). – Duncan Jones Dec 02 '13 at 11:33
  • Number is never negative, max length is 19 – Reversed Dec 02 '13 at 11:50

1 Answers1

0

Since the column value you are storing is containing only numeric value so I don't think so you should Cipher the numerical value. But yes, if you are worried about the security you can design your own mechanism to subtract a particular number from the value and store them and while retrieving you may add that particular number back to get desired result.
If you are looking for more security then read Compress large Integers into smallest possible string which will allow you to compress-decompress and yes you can play a small trick to subtract and then compress-decompress for strengthening.

So this satisfies your conditions too,

  1. The encrypted number must not exceed the DB COLUMN size (19)
  2. Database column type cannot be altered

added with some Securtiy to prevent it to be cracked easily.

Community
  • 1
  • 1
dbw
  • 6,060
  • 2
  • 22
  • 56