# Re: how to encrypt the 10-digit values into encrypted 10-digit values?

On 26 Sep., 10:08, makissy <maki...@xxxxxxxxx> wrote:
Hi All,
I have an assignment about increasing the security of the
system by encrypting the identification numbers in database.
how to encrypt the 10-digit values into encrypted 10-digit values?
i don't have any idea yet. Can anyone give me any idea. pls..

requirements
•    Each plain text 10-digit value with digits in the
interval [0..9] should be encrypted to a 10-digit number
with digits in the interval [0..9].
•    Each encrypted value of 10 digits should be possible to
decrypt back to a plain text 10-digit value.

Thanks for any guidance.

Hello,

I would do it like this (this method is easy on a piece of paper):

1) split the number into 2 rows of 5 digits
2) shift the digits in the first row 1 place the the left, and 2
places to the left

in the second row - appending the leftmost digits to the end
3) mod10 add each column's digits
4) mod10 subtract each column's calculated value from that column's
digits
5) repeat steps 2-4 (at least once)

It is very fast and very easy, and has the benefit over just simply

to the number - that it adds diffusion, a very important property in
encryption

(changing the data in the smallest amount results in changes in the
entire cipher).

Let me show an example:

Number to be encrypted: 4685197643
Secret key (that you have created somehow): 5216940876

1) split number into 2 rows
46851
97643

2) shift places to the left
68514
64397

3) mod10 add each column's digits
68514
64397
--------
22801 (modulo 10 addition of each column's digits)

4) mod10 subtract each column's calculated value from that column's
digits
46713
42596

Let me explain this step. First column:
6
6
--
2

and becomes:
4
4

because: 6-2=4, 6-2=4

Let's take the 3rd column:
5
3
--
8

becomes:
7
5

because: 5-8 = -3. We cant have a negative number, so we add 10 - and
it then

becomes 7. And the last digit: 3-8 = -5. -5 + 10 = 5

So as you can see it is pretty easy.

5) repeat steps 2-4 (at least once)
46713
42596

....shifted:
67134
59642

6) mod10 add each column's digits
67134
59642
--------
16776

7) mod10 subtract each column's calculated value from that column's
digits
51468
43976

5146843976 (straightened out)
5216940876 (key)
-----------------
0352783742 = cipher (modulo 10 addition of the number and the key)

And the encryption is done.

To decrypt, just do everything in reverse:

0352783742 (cipher)
5216940876 (key)
-----------------
5146843976 (modulo 10 subtraction)

51468
43976
--------

.... 94334 mod10 subtracted

67134
59642

.... unshift

46713
42596

.... repeat these steps once more

46713
42596
-----

.... 88209 mod10 subtracted

68514
64397

.... unshift

46851
97643

.... straighten

4685197643

And it's decrypted!

If you can't decrypt it, you made an error somewhere (errors happen
quite easily, so

you should always either: doublecheck the calculations or try to
decrypt it).
.

## Relevant Pages

• modulo encrypt problem
... I am trying to get an extremely simple character string encryption function ... The pattern to be encrypted is a string of ASCII numeric digits. ...
(comp.lang.c)
• exploring the use of manual encryption of passwords (newbie)
... an easy manual encryption scheme (i.e. no software involved other than my own ... the essence is the remaining string of digits. ... char; then extend the vector in the same direction. ...
(sci.crypt)
• Re: Search encrypted column in SQL 2005http://msdn.microsoft.com/w
... encryption process, I'll look at Raul Garcia's proposed MAC indexing ... We print the last 4 digits of the CC# on the transaction along with the ... search along with the date/time and transaction amount from our system. ... even have FBI came in to investigate fraudulent credit card activities. ...
(microsoft.public.sqlserver.security)
• Re: [C++] Encryption statistic)
... If i modulus something to get an answer.. ... One i happened to like considerably is an encryption ... | modifying each digit to some other value, then swapping digits around (the ... | to make seperate programs to do each task ...
(alt.comp.lang.learn.c-cpp)