diff --git a/components/fpspreadsheet/source/common/fpscrypto.pas b/components/fpspreadsheet/source/common/fpscrypto.pas new file mode 100644 index 000000000..b2679fb1c --- /dev/null +++ b/components/fpspreadsheet/source/common/fpscrypto.pas @@ -0,0 +1,30 @@ +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. diff --git a/components/fpspreadsheet/source/laz_fpspreadsheet.lpk b/components/fpspreadsheet/source/laz_fpspreadsheet.lpk index 672f1ed50..0f5627637 100644 --- a/components/fpspreadsheet/source/laz_fpspreadsheet.lpk +++ b/components/fpspreadsheet/source/laz_fpspreadsheet.lpk @@ -30,7 +30,7 @@ This package is all you need if you don't want graphical components (like grids and charts)."/> - + @@ -250,6 +250,10 @@ This package is all you need if you don't want graphical components (like grids + + + +