# HG changeset patch # User Claus Gittinger # Date 1580555581 -3600 # Node ID d2f8caf0e85c7f7894f1280694b32170178869f5 # Parent 138e5cbe0264b11de7d984c5cfa5476b3f08c0db #REFACTORING by exept class: WorkspaceApplication changed: #menuSaveEncryptedAs diff -r 138e5cbe0264 -r d2f8caf0e85c WorkspaceApplication.st --- a/WorkspaceApplication.st Sat Feb 01 12:11:25 2020 +0100 +++ b/WorkspaceApplication.st Sat Feb 01 12:13:01 2020 +0100 @@ -3305,29 +3305,32 @@ default:(self defaultFileNameForSave) forSave:true thenDo:[:file :doAppend | - |bs ws contents lbl cipher crypted rndBytes pos| + |bs ws contents lbl cipher crypted rndBytes pos sz fn| + + fn := file asFilename. bs := algorithm blockSize. ws := self selectedWorkspacesTextView. contents := ws contentsAsString. + sz := contents size. "/ place the size info at some random position within the random bytes rndBytes := ByteArray withAll:((Random next:64 between:1 and:255) collect:#rounded). pos := Random nextIntegerBetween:20 and:50. rndBytes at:pos put:0. - rndBytes replaceFrom:pos+1 with:(contents size printString , ' '). + rndBytes replaceFrom:pos+1 with:(sz printString , ' '). rndBytes := rndBytes asString. contents := rndBytes , contents. - contents := contents , (String new:(contents size nextMultipleOf:bs)). + contents := contents , (String new:(sz nextMultipleOf:bs)). cipher := algorithm new key:key mode:#CBC. crypted := cipher encrypt:contents. - file asFilename writingFileDo:[:s | + fn writingFileDo:[:s | s binary. s nextPutAll:crypted. ]. - ws defaultFileNameForFileDialog:file asFilename baseName. + ws defaultFileNameForFileDialog:fn baseName. ws isCodeView2 ifTrue:[ ws beUnmodified ]