sindresorhus / Actions

⚙️ Supercharge your shortcuts
https://sindresorhus.com/actions
2.68k stars 115 forks source link

more details about "encrypt text" #277

Closed junqi-lu closed 2 months ago

junqi-lu commented 2 months ago

Description

Actions is a fantastic app, and I appreciate your work.

I would like to use iOS Shortcuts to send encrypted text to a server and have it decrypted there.

I checked #220 and it seems the encryption method used is AES-256-GCM. However, I'm still unclear about the specifics of the encryption process, so I'm unable to implement the decryption using a script.

Hope to know more information about the encryption process, such as padding, nonce and tag.

macOS/iOS version

18.0

Shortcut URL

https://www.icloud.com/shortcuts/24f47ba6ce7e4d888e1fdb5afa0421ce

sindresorhus commented 2 months ago

The encryption process uses AES-256-GCM with a randomly generated 12-byte nonce. The encrypted data consists of the nonce (12 bytes), ciphertext, and authentication tag (16 bytes) concatenated together in that order. This combined data is then Base64-encoded.

There is no padding used in AES-GCM.

To decrypt the data on your server, Base64-decode the text, extract the nonce, ciphertext, and tag, and use them along with your 32-character ASCII key to perform AES-256-GCM decryption.


Tip: For how exactly to decrypt on the server, simply give ChatGPT this answer and what language you want it done in, and it should be able to produce some useful code.