【发布时间】:2010-12-05 00:36:24
【问题描述】:
我目前正在使用 RC4 算法来存储应用程序设置,当我观察输出时,它看起来很容易解码。以相同字母开头的字符串的输出看起来是相同的。
短字符串导致短输出,长字符串产生更长的输出。
但是我正在寻找可以为短字符串产生更长输出的东西。
是否有另一种算法可以创建更多“加扰”输出,即使是短字符串?
我还想为输入添加一些数据后缀或前缀,这些数据在解码后可以轻松识别并去除,以在输出上创建更多随机性。
我已经使用下面显示的 Rijndael 创建了新代码,但它仍然存在同样缺乏输出变化的问题。我怀疑在输出、IV、块填充等方面创建更多变化需要一些额外的参数。
unit testform;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, DCPrijndael, DCPsha1;
type
{ TForm1 }
TForm1 = class(TForm)
edtKeyString: TEdit;
edtInputText: TEdit;
edtEncryptedText: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure edtInputTextChange(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.edtInputTextChange(Sender: TObject);
var
Cipher: TDCP_rijndael;
begin
Cipher:= TDCP_rijndael.Create(Self);
Cipher.InitStr(edtKeyString.Text,TDCP_sha1);
edtEncryptedText.Text := Cipher.EncryptString(edtInputText.Text);
Cipher.Burn;
Cipher.Free;
end;
initialization
{$I testform.lrs}
end.
【问题讨论】:
-
如何生成用于加密数据的密钥?
-
对于异或模式的流密码,您应该只使用密钥一次。它与一次性便笺具有非常相似的属性。在适当的模式下使用块密码。如果您知道自己在做什么,则应该只使用流密码,因为它们比块密码更容易出错。
标签: encryption application-settings