[Up]: Storage API : Encrypt

File Decryption

Script path: /storage/bin/api/decrypt.cgi

Description:  Decrypt specified encrypted file(s) using a given password / passphrase as the key

INPUT (via GET or POST)

   sid => the authenticated session id  (must be valid)

path => the path to the file

Multiple paths can be specified by repeating this parameter.

(Current implementation accepts path to a file only. If the path specifies a folder, it will abort.)

path_list => JSON list of paths

Format of the JSON object is as follows:
{
"path_list" : [ path1, path2, path3 ...]
}

An alternative way to specify one or more paths. The path(s) here will merge with it the previous parameter.

(Current implementation accepts path to a file only. If the path specifies a folder, it will abort.)

passwd => password or passphrase, limited to 255 characters, alphanumerics, underscores, spaces only

delete_enc => yes

The encrypted file will be DELETED after successful decryption.
By default the encrypted file will NOT be deleted.

replace_existing_original => yes

IF there is an existing original (not encrypted) file for a given item, it will be removed and recreated.
By default this will not done.

ofmt => output format defaults to JSON format with minimal white spaces.
ofmt = jsonp means to produce JSON format in pretty printed way (easier to read)


OUTPUT (content-type: text/plain)


   JSON output object for general successful case, where each file gets decrypted.
However, the result_list needs to be inspected to see if processing result for EACH file.
result = "OK" | "FAIL" (for successful decryption or not)

{
"status" : true,
"result_list" : [
{
"itemname" : "/Private/testfolder/Български.txt/NewFile您可以使用这个.txt.enc",
"comments" : "",
"result" : "OK"
},
{
"itemname" : "/Private/testfolder/Български Espaņol.txt.enc",
"comments" : "Decryption aborted because there already exist a file named Български Espaņol.txt",
"result" : "FAIL"
},
{
"itemname" : "/Private/top_secret.txt.enc",
"comments" : "Error while decrypting: (gpg error code: 2) Incorrect passphrase.",
"result" : "FAIL"
}

]
}



JSON output object for general unsuccessful case:

{
"status" : false,
"errmsg" : "(reason for failure)"
}

e.g.
{
"status" : false,
errmsg" : "PassPhrase is empty"
}

In all cases, appropriate HTTP header status codes are also returned e.g. 200 OK, 401 Invalid user
profile, etc.


NOTES:

The original (decrypted) file will be created for each encrypted file specified in the path parameter.
This orignial file has the same name as the encrypted file but will have the end ".enc" removed.
By default the encrypted file will not be deleted. If there is an existing original (not ".enc") file for
the decrypted file, by default, it will not be replaced/overwritten.

e.g. SomeFile.txt.enc will be decrypted as SomeFile.txt

The file timestamp of the decrypted file will be made the same as the encrypted file's.

The .enc file extension is reserved for encrypted files. So, this API will not decrypt a file that
does NOT have the .enc file extension.