3 votos

¿Cómo puedo crear una imagen de bits de AES-256 con Automator?

Por defecto Automator utiliza el cifrado de 128 bits para la creación de la imagen. No quiero abrir la utilidad de discos todo el tiempo para crear imágenes encriptadas. Por lo tanto, yo, sin embargo, sobre el uso de hdiutil dentro de Automator.

¿Cómo puedo definir el origen de la ruta de la carpeta en mi flujo de trabajo? ¿Cómo puedo crear una imagen con la más alta cifrado usando Automator?

Automator Workflow

4voto

Pirooz Puntos 486

Usted no necesita de Automator para ello. Sólo uso Automators primo, AppleScript.

  1. Abrir Editor de secuencias de Comandos en /Applications/Utilities
  2. Copie y Pegue el código de abajo
  3. Vaya a Archivo>Exportar
  4. Formato De Archivo: Aplicación
  5. Arrastre los archivos y las carpetas sobre el icono (incluso se puede agregar el icono con el doc para un fácil acceso
  6. Introduzca su contraseña
  7. Se crearán los archivos en el mismo directorio con un agregado _EncryptedDMG.dmg

Código:

on open myFiles
    set theCount to 1
    display dialog "Enter the password to encrypt" default answer "" with hidden answer
    set myPassword to the text returned of the result as text
    set d to "•"
    set td to ""
    repeat length of myPassword times
        set td to td & d
    end repeat
    display dialog "Verify the password: " & td default answer "" with hidden answer
    set theVerify to the text returned of the result
    if myPassword is theVerify then
        tell application "System Events"
            repeat with myFile in myFiles
                set myPath to the POSIX path of myFile
                set myName to the characters 1 thru ((offset of "." in (name of myFile as text)) - 1) of (name of myFile as text)
                set myContainer to (the POSIX path of (container of myFile))
                do shell script "printf  \"" & myPassword & "\" |  hdiutil create -encryption AES-256 -stdinpass -srcfolder '" & myPath & "' '" & myContainer & "/" & myName & "'"
                do shell script "mv '" & myPath & "' ~/.Trash"
                display notification "File created at " & myContainer & "/" & myName & ".dmg. Original file deleted." with title "Encryption Complete" subtitle "File " & theCount & " of " & (length of myFiles) sound name "glass"
            end repeat
        end tell
    else
        display dialog "Error: Passwords did not match"
    end if
end open

Si desea añadir al menú contextual copiar y pegar el siguiente código en un "Ejecutar Script de Apple" de Acción.

on run {myFiles, parameters}
    set theCount to 1
    display dialog "Enter the password to encrypt" default answer "" with hidden answer
    set myPassword to the text returned of the result as text
    set d to "•"
    set td to ""
    repeat length of myPassword times
        set td to td & d
    end repeat
    display dialog "Verify the password: " & td default answer "" with hidden answer
    set theVerify to the text returned of the result
    if myPassword is theVerify then
        tell application "System Events"
            repeat with myFile in myFiles
                set myPath to the POSIX path of myFile
                set myName to the characters 1 thru ((offset of "." in (name of myFile as text)) - 1) of (name of myFile as text)
                set myContainer to (the POSIX path of (container of myFile))
                do shell script "printf  \"" & myPassword & "\" |  hdiutil create -encryption AES-256 -stdinpass -srcfolder '" & myPath & "' '" & myContainer & "/" & myName & "'"
                do shell script "mv '" & myPath & "' ~/.Trash"
                display notification "File created at " & myContainer & "/" & myName & ".dmg. Original file deleted." with title "Encryption Complete" subtitle "File " & theCount & " of " & (length of myFiles) sound name "glass"
            end repeat
        end tell
    else
        display dialog "Error: Passwords did not match"
    end if
end run

Al abrir Automator seleccione Menú Contextual y, a continuación, seleccione estas opciones

enter image description here

Nota: Usted estará encantado de escuchar, macOS Mojave traerá similar funcionalidad de forma nativa. No es un complemento de la contraseña en el menú contextual que comprime y encripta el archivo similar a cómo esta aplicación lo hace, pero todavía no hay barra de progreso.

2voto

wch1zpink Puntos 11

Sentí que había bastantes diferencias entre mi solución y el otro publicado respuesta, como para ofrecer este script como otra respuesta al post original.

Guardar este script como una aplicación en ScriptEditor app

Esta secuencia de comandos le permite al usuario colocar varios archivos o carpetas, directamente sobre este icono de aplicación... Y también le da al usuario la opción de si desea conservar o eliminar el original de los archivos o carpetas.

Si esta secuencia de comandos de la aplicación que se ejecuta en el modo normal, haciendo doble clic en la aplicación, el usuario tiene la opción de elegir uno o varios archivos o elegir una sola o varias carpetas, para ser procesados. Además, el usuario tiene la opción de eliminar o mantener los archivos originales.

Esto ha sido probado con la última versión de macOS Alta Sierra

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

global deleteFiles, isTrue, theCount, myPassword, theName

on open theFiles
    --HANDLE THE CASE WHERE THE SCRIPT IS LAUNCHED BY DROPPING FILES ONTO APP ICON
    repeat with i from 1 to count of theFiles
        set thisItem to item i of theFiles
        set isTrue to missing value
        set theCount to 0
        set theName to missing value
        set theFolder to thisItem
        tell application "Finder"
            set theContainer to container of theFolder as alias
            set theName to name of (get properties of theFolder)
        end tell
        run my setPassword
        run my keepOriginals
        set myPath to POSIX path of theFolder
        set theContainer to POSIX path of theContainer
        do shell script "printf  \"" & myPassword & "\" |  hdiutil create -encryption AES-256 -stdinpass -srcfolder '" & ¬
            myPath & "' '" & theContainer & theName & "_Encrypted'"
        if deleteFiles = true then
            tell application "Finder" to delete theFolder
        end if
    end repeat
end open

on run
    --HANDLE THE CASE WHERE THE SCRIPT IS LAUNCHED WITHOUT ANY DROPPED FILES
    activate
    set theChoice to display dialog ¬
        "WOULD YOU LIKE TO CHOOSE FILES OR FOLDERS?" buttons {"Cancel", "Choose Files", "Choose Folders"} ¬
        default button ¬
        "Choose Folders" cancel button ¬
        "Cancel" with title ¬
        "Make Your Choice" with icon 1 ¬
        giving up after 20
    if button returned of theChoice is "Choose Files" then
        run my chooseFiles
    else if button returned of theChoice is "Choose Folders" then
        run my chooseFolders
    else if button returned of theChoice is "" then
        return
    end if
end run

script chooseFiles
    activate
    set theFiles to (choose file with multiple selections allowed)
    repeat with i from 1 to count of theFiles
        set thisItem to item i of theFiles
        set isTrue to missing value
        set theCount to 0
        set theName to missing value
        set theFolder to thisItem
        tell application "Finder"
            set theContainer to container of theFolder as alias
            set theName to name of (get properties of theFolder)
        end tell
        run my setPassword
        run my keepOriginals
        set myPath to POSIX path of theFolder
        set theContainer to POSIX path of theContainer
        do shell script "printf  \"" & myPassword & "\" |  hdiutil create -encryption AES-256 -stdinpass -srcfolder '" & ¬
            myPath & "' '" & theContainer & theName & "_Encrypted'"
        if deleteFiles = true then
            tell application "Finder" to delete theFolder
        end if
    end repeat
end script

script chooseFolders
    activate
    set theFiles to (choose folder with multiple selections allowed)
    repeat with i from 1 to count of theFiles
        set thisItem to item i of theFiles
        set isTrue to missing value
        set theCount to 0
        set theName to missing value
        set theFolder to thisItem
        tell application "Finder"
            set theContainer to container of theFolder as alias
            set theName to name of (get properties of theFolder)
        end tell
        run my setPassword
        run my keepOriginals
        set myPath to POSIX path of theFolder
        set theContainer to POSIX path of theContainer
        do shell script "printf  \"" & myPassword & "\" |  hdiutil create -encryption AES-256 -stdinpass -srcfolder '" & ¬
            myPath & "' '" & theContainer & theName & "_Encrypted'"
        if deleteFiles = true then
            tell application "Finder" to delete theFolder
        end if
    end repeat
end script

script failedPassVerify
    activate
    display dialog ¬
        "You Have Unsuccessfully Verified Your Password 3 Times In A Row... Please Try Again Later" buttons {"OK"} ¬
        default button ¬
        "OK" with title ¬
        "UNSUCCESSFUL PASSWORD VERIFICATION" with icon 0 ¬
        giving up after 10
    quit me
end script

script keepOriginals
    set keepOrDelete to display dialog ¬
        ("Would You Like To Delete The Original Item... " & theName & "?") buttons {"DELETE ORIGINALS", "KEEP ORIGINALS"} ¬
        default button 2 ¬
        with title ¬
        "KEEP OR DELETE ORIGINALS?" with icon 0 ¬
        giving up after 30
    if button returned of keepOrDelete is "DELETE ORIGINALS" then
        set deleteFiles to true
    else if button returned of keepOrDelete is "KEEP ORIGINALS" then
        set deleteFiles to false
    else if button returned of keepOrDelete is "" then
        set deleteFiles to false
    end if
end script

script setPassword
    repeat until isTrue = true
        activate
        set myPassword to text returned of (display dialog ¬
            ("ENTER THE PASSWORD TO ENCRYPT DISK IMAGE " & theName) default answer "" with hidden answer)
        activate
        set myPassword2 to text returned of (display dialog ¬
            "PLEASE VERIFY YOUR PASSWORD" default answer "" with hidden answer)
        set isTrue to myPassword2 = myPassword
        if isTrue = false then
            set theCount to theCount + 1
            if theCount = 3 then
                run my failedPassVerify
            end if
            activate
            display alert ¬
                "PASSWORDS DO NOT MATCH" message ¬
                "PASSWORDS DO NOT MATCH" giving up after 3
        end if
    end repeat
end script

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X