How do I encrypt a string and get a equal length encrypted string?

后端 未结 8 1047
南笙
南笙 2020-12-09 05:55

My problem is the following:

In an existing database I want to encrypt data in a couple of columns. The columns contains strings of different lengths.

I don\

8条回答
  •  一向
    一向 (楼主)
    2020-12-09 06:26

    The Vigenère cipher can do that. But it is old (pre-computer) and only secure if your key phrase is longer than the longest string you want to encrypt. Plus, having a database full of strings encrypted with the same key phrase will probably make this a week encryption, especially if the plain texts can be guessed.

    It works more or less like the cesar shift algorithm (add n to each letter in plain text), except that n is different for each letter being changed, based on a key phrase.

    If your key phrase is ABCDEFG, then it means n=1 for first letter of input, 2 for second letter of input etc.

    With a random key phrase longer than the plain text, the output is just as random (secure). But I believe this will break down if you have many strings encrypted with the same key. ..

提交回复
热议问题