From ffceb1932b5d319999aab164b7369bdc43f91b37 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 5 Mar 2017 11:44:32 +0000 Subject: [PATCH] fpspreadsheet: Add new unit fpscrypto.pas. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5787 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../fpspreadsheet/source/common/fpscrypto.pas | 30 +++++++++++++++++++ .../source/laz_fpspreadsheet.lpk | 6 +++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 components/fpspreadsheet/source/common/fpscrypto.pas 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 + + + +