[英]The stored password in the db slightly changed through storing process from the original encryption
我使用 Delphi 10.4 社區版和 Firebird 嵌入式數據庫。
問題:我通常將登錄密碼存儲在加密的“用戶”表中。 這是我通常使用的算法(我知道它不是最難破解的,但這個軟件只適合我自己所以誰會煩惱?)
function Titkositas(Jelszo: string; Code: LongInt): string;
var
Ciklus: Byte;
begin
RandSeed := Code;
Result := '';
for Ciklus := 1 to Length(Jelszo) do
Result := Result + Chr(Ord(Jelszo[Ciklus]) xor Random(256));
end;
加密后,我將其存儲在表中。
procedure TFrmadmin2.BitBtn5Click(Sender: TObject);
var
s, s2, m, t, dt, most: string;
begin
s := '';
s2 := '';
m := '';
t := ''; dt:=''; most:='';
if trim(edit3.Text) = trim(edit4.Text) then
begin
if ((edit1.text <> '') and (edit2.text <> '') and (edit3.text <> '') and (edit4.text <> '')) then
begin
if (not TDM1.MenuTrans.InTransaction) then
TDM1.MenuTrans.StartTransaction;
try
with insertuser do
begin
prepare;
begin
ParamByName('NEV').asString := trim(edit1.Text);
ParamByName('LOGIN').asString := trim(edit2.Text);
ParamByName('PASSWD').asString := Titkositas(trim(edit4.text), 123456); //this is it!!!
listbox1.items.add(Titkositas(trim(edit4.text), 123456));
ParamByName('JOG').AsInteger := strtoint(trim(edit5.Text));
dt:=DateTimeToStr(now);
ParamByname('DATUM').Asstring :=dt;
execproc;
if TDM1.MenuTrans.InTransaction then TDM1.MenuTrans.CommitRetaining;
....
所以,它在過去工作得很好,但現在我注意到加密功能不正常(或其他)。 我不知道問題可能是什么:所以這應該是加密后的密碼: a÷~D 2¥
但是表中存儲的是: a÷~D 2Y
你能看出細微的差別嗎? 這意味着當我嘗試登錄時它不起作用,因為我知道的密碼已通過存儲過程更改。 我認為這可能是因為我注冊的 Firebird 數據庫的字符集。 我將其更改為默認的 Unicode、ISO-1,但沒有任何更改。
我仔細檢查了上面的代碼,所以我在顯示正確結果的 showmessage 中打印出加密密碼,然后一行一行地調試它,當它被執行時它仍然顯示正確的加密字符但是當我檢查表時它略有不同。
有沒有人知道問題可能是什么?
異或字符串不再是字符串。 它是一個字節數組。 您不能將其作為字符串處理、存儲為字符串等,因為對於字符串而言,有效代碼的范圍是有限的,並且字符集之間的字符串轉換可能是不可逆的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.