Files
lazarus-ccr/components/fpspreadsheet/source/common/fpscrypto.pas
wp_xxyyzz ffceb1932b fpspreadsheet: Add new unit fpscrypto.pas.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5787 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2017-03-05 11:44:32 +00:00

31 lines
574 B
ObjectPascal

unit fpsCrypto;
interface
uses
SysUtils;
function ExcelPasswordHash(const APassword: String): String;
implementation
{@@ This is the code for generating Excel 2010 and earlier password's hash }
function ExcelPasswordHash(const APassword: string): string;
const
Key = $CE4B;
var
i: Integer;
HashValue: Word = 0;
begin
for i:= Length(APassword) downto 1 do
begin
HashValue := ord(APassword[i]) xor HashValue;
HashValue := HashValue shl 1;
end;
HashValue := HashValue xor Length(APassword) xor Key;
Result := IntToHex(HashValue, 4);
end;
end.