AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi Fehler bei Übergabe eines Salts an BCrypt
Thema durchsuchen
Ansicht
Themen-Optionen

Fehler bei Übergabe eines Salts an BCrypt

Ein Thema von Aviator · begonnen am 18. Okt 2016 · letzter Beitrag vom 18. Okt 2016
Antwort Antwort
gammatester

Registriert seit: 6. Dez 2005
999 Beiträge
 
#1

AW: Fehler bei Übergabe eines Salts an BCrypt

  Alt 18. Okt 2016, 14:33
Oder weist Du die Ergebnisse bc.HashPassword einem string zu? mystr := bc.HashPassword(Password, guid.D4, 12); Da die Deklaration so aussieht
Delphi-Quellcode:
//If you want to handle the cost, salt, and encoding yourself, you can do that.
class function HashPassword(const password: UnicodeString; const salt: array of Byte; const cost: Integer): TBytes; overload;
erhälts Du ein Ergebnis vom Typ TBytes, was manche Fehlermeldungen erklären würde.
  Mit Zitat antworten Zitat
Aviator

Registriert seit: 3. Jun 2010
1.611 Beiträge
 
Delphi 10.3 Rio
 
#2

AW: Fehler bei Übergabe eines Salts an BCrypt

  Alt 18. Okt 2016, 15:12
Oder weist Du die Ergebnisse bc.HashPassword einem string zu? mystr := bc.HashPassword(Password, guid.D4, 12); Da die Deklaration so aussieht
Delphi-Quellcode:
//If you want to handle the cost, salt, and encoding yourself, you can do that.
class function HashPassword(const password: UnicodeString; const salt: array of Byte; const cost: Integer): TBytes; overload;
erhälts Du ein Ergebnis vom Typ TBytes, was manche Fehlermeldungen erklären würde.
Oh mann.

Das war es. Der Rückgabetyp dieser Funktion ist ein anderer. Manchmal sieht man den Wald vor lauter Bäuimen nicht. Die Frage ist nur, warum die Funktion einen anderen Rückgabetyp hat.

So funktioniert es jetzt.

Delphi-Quellcode:
function HashPassword(const Password: string): string;
var
  bc: TBCrypt;
  guid: TGUID;
  tb: TBytes;
begin
  Result := EmptyStr;
  bc := TBCrypt.Create;
  try
  guid := TGUID.Create;
  tb := bc.HashPassword(Password, guid.ToByteArray, 12);
  Result := TEncoding.Unicode.GetString(tb);
  finally
    bc.Free;
  end;
end;
EDIT: Etwas zu früh gefreut. Die Zeile Result := TEncoding.Unicode.GetString(tb); macht noch ein paar Probleme. Da kommt im Moment nur Müll raus.

Wie kann ich TBytes in String umwandeln, sodass nochmal ein Hash rauskommt?

Geändert von Aviator (18. Okt 2016 um 15:17 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz