Skip to content

Commit

Permalink
DecryptDirListing routine
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Nov 8, 2017
1 parent 9c2b644 commit 5dfbc63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMLJSON.pas
Expand Up @@ -61,6 +61,7 @@ function fromJSON_DirListing(JSON: WideString; var CloudMailRuDirListing: TCloud
home := ParserObj.Values['home'].Value;
if Assigned(ParserObj.Values['name']) then
name := ParserObj.Values['name'].Value;
visible_name := name;
if Assigned(ParserObj.Values['deleted_at']) then
deleted_at := ParserObj.Values['deleted_at'].Value.ToInteger;
if Assigned(ParserObj.Values['deleted_from']) then
Expand Down
1 change: 1 addition & 0 deletions CMLTypes.pas
Expand Up @@ -113,6 +113,7 @@ interface
TCloudMailRuDirListingItem = Record
tree: WideString;
name: WideString;
visible_name: WideString;
grev: integer;
size: int64;
kind: WideString;
Expand Down
19 changes: 15 additions & 4 deletions Cipher.pas
Expand Up @@ -3,7 +3,7 @@
interface

{Сначала реализация, потом рефакторинг. Шифрование будет каким-нибудь интерфейсом описано, а это уедет в реализацию}
uses System.SysUtils, System.Classes, DCPcrypt2, DCPblockciphers, DCPrijndael, DCPSha1, DCPbase64;
uses System.SysUtils, System.Classes, CMLTypes, DCPcrypt2, DCPblockciphers, DCPrijndael, DCPSha1, DCPbase64;

const
CIPHER_OK = 0;
Expand Down Expand Up @@ -38,6 +38,7 @@ TFileCipher = class
function DecryptFile(SourceFileName, DestinationFilename: WideString): integer;
function DecryptStream(SourceStream, DestinationStream: TStream): integer;
function DecryptFileName(const FileName: WideString): WideString;
procedure DecryptDirListing(var CloudMailRuDirListing: TCloudMailRuDirListing);

class function Base64ToSafe(const Base64: WideString): WideString; //converts Base64-encoded string to URL and Filename safe (RFC 4648)
class function Base64FromSafe(const Safe: WideString): WideString;
Expand Down Expand Up @@ -151,6 +152,16 @@ function TFileCipher.CryptStream(SourceStream, DestinationStream: TStream): inte
self.CiphersDestroy;
end;

procedure TFileCipher.DecryptDirListing(var CloudMailRuDirListing: TCloudMailRuDirListing);
var
i: integer;
begin
for i := 0 to Length(CloudMailRuDirListing) - 1 do
begin
CloudMailRuDirListing[i].visible_name := self.DecryptFileName(CloudMailRuDirListing[i].name);
end;
end;

function TFileCipher.DecryptFile(SourceFileName, DestinationFilename: WideString): integer;
var
SourceStream, DestinationStream: TFileStream;
Expand Down Expand Up @@ -194,9 +205,9 @@ function TFileCipher.DecryptStream(SourceStream, DestinationStream: TStream): in

destructor TFileCipher.Destroy;
begin
{ self.fileCipher.Destroy;
if Assigned(self.filenameCipher) then
self.filenameCipher.Destroy; }
{self.fileCipher.Destroy;
if Assigned(self.filenameCipher) then
self.filenameCipher.Destroy;}
inherited;
end;

Expand Down

0 comments on commit 5dfbc63

Please sign in to comment.