#REFACTORING by exept
authorClaus Gittinger <cg@exept.de>
Sat, 01 Feb 2020 12:13:01 +0100
changeset 19444 d2f8caf0e85c
parent 19443 138e5cbe0264
child 19445 8983ba30d719
#REFACTORING by exept class: WorkspaceApplication changed: #menuSaveEncryptedAs
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
             ]