Changing Between Blowfish and AES Encryption
From Apache OpenOffice Wiki
Macro Source
Option Explicit Sub EncryptionToggle REM Toggle encryption mode between SHA1/Blowfish and SHA256/AES. REM Author: T.J. Frazier 2012-April REM License: ALv2 Const sPathODF as String = "/org.openoffice.Office.Common/Save/ODF" Const sAES as String = "SHA256 / AES" Const sBlow as String = "SHA1 / Blowfish" Dim Args(0) as New com.sun.star.beans.NamedValue 'params for update Args(0).Name = "nodePath" Args(0).Value = sPathODF Dim bNew as Boolean 'New option value Dim bOld as Boolean 'Previous option setting Dim iAnswer as Integer 'Msgbox reply Dim oConfig as Object 'Partial configuration data Dim oProvider as Object 'Configuration Provider Dim s as String 'scratch Dim sWas as String 'describes previous option Dim sNew as String 'describes new option s = "com.sun.star.comp.configuration.ConfigurationProvider" oProvider = createUnoService(s) s = "com.sun.star.configuration.ConfigurationUpdateAccess" oConfig = oProvider.createInstanceWithArguments(s, Args()) bOld = oConfig.UseBlowfishInODF12 If bOld Then 'Blowfish is current sWas = sBlow sNew = sAES Else 'AES is current sWas = sAES sNew = sBlow EndIf 'Blowfish active iAnswer = Msgbox( "Current encryption is " & sWas & "." & chr(13) _ & "Change to " & sNew & " instead?" & chr(13), _ MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2, _ "Change File Encryption" ) If iAnswer = IDYES Then bNew = Not bOld oConfig.UseBlowfishInODF12 = bNew oConfig.UseSHA1InODF12 = bNew oConfig.commitChanges() Msgbox "When you drop and restart OpenOffice (including the Quickstarter)," _ & "this change will take effect.", MB_OK + MB_ICONINFORMATION, _ "File Encryption Changed to " & sNew EndIf 'user said Yes End Sub 'EncryptionToggle