crab-gnupg 0.1.3

API for GNU Privacy Guard (GnuPG) written in rust. Manage gpg keys and secure files using rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# ⚙️ Usage
- [Initialize gpg]#initialize-gpg
- [Generate key]#generate-key
- [List keys]#list-keys
- [Delete keys]#delete-keys
- [Add subkeys]#add-subkeys
- [Revoke key]#revoke-key
- [Import keys]#import-keys
- [Export public keys]#export-public-keys
- [Export secret keys]#export-secret-keys
- [Trust key]#trust-key
- [Sign key]#sign-key
- [Encrypt file]#encrypt-file
- [Decrypt file]#decrypt-file
- [Sign file]#sign-file
- [Verify file]#verify-file

 
# 🔠 Type
- [GPG]#gpg
- [CmdResult]#cmdresult
- [GPGError]#gpgerror
- [ListKeyResult]#listkeyresult
- [EncryptOption]#encryptoption
- [DecryptOption]#decryptoption
- [SignOption]#signoption

 
# #️⃣ Enum
- [TrustLevel]#trustlevel

 
## Initialize gpg
Before any operation of gpg, a gpg object need to be initialized to get access to other gpg function.  
`GPG::init()` takes in 3 parameter in the following sequence.
| parameter  | type             | description                                                                                |
|------------|------------------|--------------------------------------------------------------------------------------------|
| homedir    | `Option<String>` | Path where gpg store key, if `None` default to `~/.gnupg` for unix or `~/gnupg` for window |
| output_dir | `Option<String>` | Path where gpg will save output files to, if `None` default to `~/Downloads/gnupg_output`  |
| armor      | `bool`           | If output should be ASCII armoured                                                         |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
```

&nbsp;
## Generate key
To generate gpg key, you can use the function of `gen_key()` provided by `GPG`.  
`gen_key()` takes in 2 parameters in the following sequence.
| parameter        | type                              | description                                                                                                   |
|------------------|-----------------------------------|---------------------------------------------------------------------------------------------------------------|
| key_passphrase   | `Option<String>`                  | Passphrase for passphrase protected key, if not provided, the key generated will not be passphrase protected  |
| args             | `Option<HashMap<String, String>>` | Additional args provided for key generation, check GnuPG official documentation for detail available arguments|

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result:Result<CmdResult, GPGError> = gpg.gen_key("example-passphrase".to_string(), None)
```

&nbsp;
## List keys
To list gpg key, you can use the function of `list_keys()` provided by `GPG`.  
`list_keys()` takes in 3 parameters in the following sequence.
| parameter| type                  | description                                                                                                  |
|----------|-----------------------|--------------------------------------------------------------------------------------------------------------|
| secret   | `bool`                | If `true` list secret keys instead of public keys                                                            |
| keys     | `Option<Vec<String>>` | If provided, only list keys that matches the provided keyid(s) instead of all the keys in gpg home directory |
| signature| `bool`                | If `true`, also include signature to the listing of keys                                                     |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.list_keys()
```

&nbsp;
## Delete keys
To delete gpg key, you can use the function of `delete_keys()` provided by `GPG`.  
`delete_keys()` takes in 4 parameters in the following sequence.
| parameter    | type               | description                                       |
|--------------|--------------------|---------------------------------------------------|
| fingerprints | `Vec<String>`      | List of fingerprints of keys to delete            |
| is_secret    | `bool`             | If `true`, delete secret keys only                |
| is_subkey    | `bool`             | If `true`, delete subkeys instead                 |
| passphrase   | `Option<String>`   | Passphrase for passphrase protected secret keys   |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.delete_keys(vec!["< FINGERPRINT >"], false, false, None);
```

&nbsp;
## Add subkeys
To add a subkey to an existing gpg key, you can use the function of `add_subkey()` provided by `GPG`.  
`add_subkey()` takes in 5 parameters in the following sequence.
| parameter    | type               | description                                                                               |
|--------------|--------------------|-------------------------------------------------------------------------------------------|
| fingerprint  | `String`           | Finerprint of the parent key that the subkey will be added to                             |
| passphrase   | `Option<String>`   | Passphrase of the parent key if it was passphrase protected                               |
| algo         | `String`           | Algorithm of the subkey. e.g) "rsa", "dsa" etc                                            |
| usage        | `String`           | Capabilities of the subkey. e.g) "sign", "encrypt" etc                                    |
| expire       | `String`           | When the subkey will expire. Provide in ISO-format YYYY-MM-DD or "-" for no expiration    |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.add_subkey(vec!["< FINGERPRINT >"], false, false, None);
```

&nbsp;
## Revoke key
To revoke the entire gpg key or one of its subkeys, you can use the function of `revoke_key()` provided by `GPG`.  
`revoke_key()` takes in 5 parameters in the following sequence.
| parameter    | type               | description                                                                                                                                                            |
|--------------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| keyid        | `String`           | The keyid of the key to revoke                                                                                                                                         |
| passphrase   | `Option<String>`   | Passphrase of the key if it was passphrase protected                                                                                                                   |
| reason_code  | `u8`               | Reason code for revocation. Choose between 0~3.                                                                                                                        |
| revoke_desc  | `Option<String>`   | A description for the revocation                                                                                                                                       |
| is_subkey    | `Option<String>`   | To indicate a revocation of the subkey only. If a subkey keyid is provided but this is not marked as `true`, the revocation of the entire parent key will be performed |


> [!NOTE]
> Description for Reason Code:   
> 0 = No reason specified  
> 1 = Key has been compromised  
> 2 = Key is superseded  
> 3 = Key is no longer used  

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)

// for entire key revocation
let result: Result<CmdResult, GPGError> = gpg.revoke_key(" <KEYID> ".to_string(), Some(" <PASSPHRASE> ".to_string()),3, None, false);

// for subkey revocation
let result: Result<CmdResult, GPGError> = gpg.revoke_key(" <KEYID> ".to_string(), Some(" <PASSPHRASE> ".to_string()),3, None, true);
```

&nbsp;
## Import keys
To import gpg key, you can use the function of `import_key()` provided by `GPG`.  
`import_key()` takes in 4 parameters in the following sequence.
| parameter  | type                  | description                                                                                            |
|------------|-----------------------|--------------------------------------------------------------------------------------------------------|
| file       | `Option<File>`        | File for importing keys ( will be priotize if provided )                                               |
| file_path  | `Option<String>`      | File for importing keys, will be ignored if file is provided                                           |
| merge_only | `bool`                | If `true`, does not insert new keys but does only the merging of new signatures, user-IDs, subkeys etc |
| extra_args | `Option<Vec<String>>` | Additional args provided for importing keys                                                            |

Example:
```rust
use crab_gnupg::gnupg::GPG;
use std::fs::File;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)

// using file
let file:File = File::open("< FILE_PATH >".to_string()).unwrap();
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.import_key(Some(), None, false, None);

// using file path
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.import_key(None, Some("< FILE_PATH >".to_string()), false, None);
```

&nbsp;
## Export public keys
To export public gpg key, you can use the function of `export_public_key()` provided by `GPG`.  
`export_public_key()` takes in 2 parameters in the following sequence.
| parameter | type                  | description                                                                                                                                       |
|-----------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| key_id    | `Option<Vec<String>>` | List of keyid(s) to export, if `None`, all public keys will be exported                                                                           |
| output    | `Option<String>`      | Path that the exported key file will be saved to, if `None` default to `~/Downloads/gnupg_output/exported_public_key/public_key_< TIMESTAMP >.asc`|

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.export_public_key(None, None);
```

&nbsp;
## Export secret keys
To export secret gpg key, you can use the function of `export_secret_key()` provided by `GPG`.  
`export_secret_key()` takes in 3 parameters in the following sequence.
| parameter | type                  | description                                                                                                                                       |
|-----------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| key_id    | `Option<Vec<String>>` | List of keyid(s) to export, if `None`, all secret keys will be exported                                                                           |
| passphrase| `Option<String>`      | Passphrase for passphrase protected secret keys. For gpg version > 2.1, this is required for passphrase proctected secret keys                    |
| output    | `Option<String>`      | Path that the exported key file will be saved to, if `None` default to `~/Downloads/gnupg_output/exported_secret_key/secret_key_< TIMESTAMP >.asc`|

> [!NOTE] 
> If there are 2 or more secret key that are passphrase proctected ( but different passphrase ) are being exported, only keys that are protected by the provided passphrase and keys that aren't passphrase protected will be exported. ( as GPG can only read 1 passphrase at a time from STDIN)

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result:Result<Vec<ListKeyResult>, GPGError> = gpg.export_secret_key(None, None, None);
```

&nbsp;
## Trust key
To trust gpg key, you can use the function of `trust_key()` provided by `GPG`.  
`trust_key()` takes in 2 parameters in the following sequence.
| parameter    | type          | description                                                                                 |
|--------------|---------------|---------------------------------------------------------------------------------------------|
| fingerprints | `Vec<String>` | List of keyid(s) to trust                                                                   |
| trust_level  | `TrustLevel`  | Trust level to set for the keys, see [TrustLevel]#trustlevel for all available option     |

Example:
```rust
use crab_gnupg::{
    gnupg::GPG,
    utils::enums::TrustLevel
};

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result: Result<CmdResult, GPGError> = gpg.trust_key(vec!["< FINGERPRINT >".to_string()], TrustLevel::Fully);
```

&nbsp;
## Sign key
To sign gpg key, you can use the function of `sign_key()` provided by `GPG`.  
`sign_key()` takes in 4 parameters in the following sequence.
| parameter      | type                   | description                                                             |
|----------------|------------------------|-------------------------------------------------------------------------|
| signing_key_id | `String`               | Keyid of the key that was used for signing                              |
| target_key_id  | `String`               | Keyid of the key that will be signed                                    |
| passphrase     | `Option<String>`       | Passphrase for passphrase protected secret keys (signing key)           |
| extra_args     | `Option<Vec<String>>`  | Additional args provided for signing keys                               |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result: Result<CmdResult, GPGError> = gpg.sign_key(
    "< SIGNING_KEY_ID >".to_string(), 
    "< TARGET_KEY_ID >".to_string(), 
    None, 
    None
);
```

&nbsp;
## Encrypt file
To encrypt file, you can use the function of `encrypt()` provided by `GPG`.  
`encrypt()` takes in 1 parameters in the following sequence.
| parameter         | type                   | description                                                                                          |
|-------------------|------------------------|------------------------------------------------------------------------------------------------------|
| encryption_option | `EncryptOption`        | a struct to represent GPG encryption option. Refer [EncryptOption]#encryptoption for more detail   |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let options: EncryptOption = EncryptOption::default(Some(file), None, vec![" <receipient> ".to_string()], Some(" <OUTPUT> ".to_string()));
let result: Result<CmdResult, GPGError> = gpg.encrypt(option);
```

&nbsp;
## Decrypt file
To decrypt file, you can use the function of `decrypt()` provided by `GPG`.  
`decrypt()` takes in 1 parameters in the following sequence.
| parameter      | type                   | description                                                                                          |
|----------------|------------------------|------------------------------------------------------------------------------------------------------|
| decrypt_option | `DecryptOption`        | a struct to represent GPG decrypt option. Refer [DecryptOption]#decryptoption for more detail      |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let options: DecryptOption = DecryptOption::default(Some(file), None, " <receipient> ".to_string(), Some(" <KEY_PASSPHRASE> ".to_string()), Some(" <OUTPUT> ".to_string()));
let result: Result<CmdResult, GPGError> = gpg.decrypt(option);
```

&nbsp;
## Sign file
To sign file, you can use the function of `sign()` provided by `GPG`.  
`sign()` takes in 1 parameters in the following sequence.
| parameter   | type                | description                                                                              |
|-------------|---------------------|------------------------------------------------------------------------------------------|
| sign_option | `SignOption`        | a struct to represent GPG sign option. Refer [SignOption]#signoption for more detail   |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let options: SignOption = SignOption::default(Some(file), None, " <keyid> ".to_string(), Some(" <KEY_PASSPHRASE> ".to_string()), Some(" <OUTPUT> ".to_string()));
let result: Result<CmdResult, GPGError> = gpg.sign(option);
```

&nbsp;
## Verify file
To verify file, you can use the function of `verify_file()` provided by `GPG`.  
`verify_file()` takes in 4 parameters in the following sequence.
| parameter           | type                  | description                                                |
|---------------------|-----------------------|------------------------------------------------------------|
| file                | `Option<File>`        | File object                                                |
| file_path           | `Option<String>`      | Path for the file, will be ignored if file is provided     |
| signature_file_path | `Option<String>`      | Path to the signature file ( if signature is detached )    |
| extra_args          | `Option<Vec<String>>` | Additional args provided for verifying file                |

Example:
```rust
use crab_gnupg::gnupg::GPG;

let gpg:Result<GPG, GPGError> = GPG::init(None, None, true)
let result: Result<CmdResult, GPGError> = gpg.verify_file(Some(file), None, None, None);
```

---
&nbsp;
## GPG
| parameter           | type                              | description                                                                                                        |
|---------------------|-----------------------------------|--------------------------------------------------------------------------------------------------------------------|
| homedir             | `String`                          | A path to a directory where the local key were at.                                                                 |
| output_dir          | `String`                          | A path to a directory where the output files from gpg will save to.                                                |
| env                 | `Option<HashMap<String, String>>` | A haspmap of env variables that would be passed to process.                                                        |
| keyrings            | `Option<Vec<String>>`             | A list of name of keyring files to use. If provided, the default keyring will be ignored.  (Currently not in used) |
| secret_keyring      | `Option<Vec<String>>`             | A list of name of secret keyring files to use. (Currently not in used)                                             |
| options             | `Option<Vec<String>>`             | Additional arguments to be passed to gpg                                                                           |
| armour              | `bool`                            | A boolean to indicate if the output should be armored                                                              |
| version             | `f32`                             | The major minor version of gpg, should only be set by system, user should not set this ex. 2.4                     |
| full_version        | `String`                          | The full version of gpg, should only be set by system, user should not set this ex. 2.4.6                          |


&nbsp;
## CmdResult
| parameter           | type                                   | description                                                                                                        |
|---------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| raw_data            | `Option<String>`                       | Raw data of gpg command response and output                                                                        |
| return_code         | `Option<i32>`                          | Return status code of gpg operation                                                                                |
| status              | `Option<String>`                       | Status of the current Command Result                                                                               |
| status_message      | `Option<String>`                       | Description about status                                                                                           |
| operation           | `Operation`                            | The current gpg operation                                                                                          |
| debug_log           | `Option<Vec<String>>`                  | Log for debug purpose                                                                                              |
| problem             | `Option<Vec<HashMap<String, String>>>` | Description for more insight about the problem if gpg operation fail                                               |
| success             | `bool`                                 | If the operation is a success                                                                                      |

&nbsp;
## GPGError
| parameter           | type                                   | description                                                                                                        |
|---------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| error_type          | `GPGErrorType`                         | The type of error                                                                                                  |
| cmd_result          | `Option<CmdResult>`                    | Provide more insight if error occured during the gpg cmd process                                                   |

&nbsp;
## ListKeyResult
Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS for full description of each corresponding parameter
| parameter           | type                                   | description                                                                                                        |
|---------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| type                | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-1---type-of-record                                |
| validity            | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-2---validity                                      |
| length              | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-3---key-length                                    |
| algo                | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-4---public-key-algorithm                          |
| keyid               | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-5---keyid                                         |
| date                | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-6---creation-date                                 |
| expire              | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-7---expiration-date                               |
| dummy               | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-8---certificate-sn-uid-hash-trust-signature-info  |
| ownertrust          | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-9----ownertrust                                   |
| uid                 | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-10---user-id                                      |
| sig                 | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-11---signature-class                              |
| cap                 | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-12---key-capabilities                             |
| issuer              | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-13---issuer-certificate-fingerprint-or-other-info |
| flag                | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-14---flag-field                                   |
| token               | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-15---sn-of-a-token                                |
| hash                | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-16---hash-algorithm                               |
| curve               | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-17---curve-name                                   |
| compliance          | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-18---compliance-flags                             |
| updated             | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-19---last-update                                  |
| origin              | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-20---origin                                       |
| comment             | `String`                               | Check https://github.com/gpg/gnupg/blob/master/doc/DETAILS#field-21---comment                                      |
| keygrip             | `String`                               | Keygrip                                                                                                            |
| uids                | `Vec<String>`                          | List of uid(s)                                                                                                     |
| sigs                | `Vec<Vec<String>>`                     | List of sig(s)                                                                                                     |
| subkeys             | `Vec<Subkey>`                          | List of subkey(s)                                                                                                  |
| fingerprint         | `String`                               | Fingerprint of the key                                                                                             |

&nbsp;
## EncryptOption
EncryptOption was taken in by `encrypt()` function provided by `GPG`.
| parameter           | type                                   | description                                                                                                                                                                     |
|---------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                     |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                    |
| recipients          | `Option<Vec<String>>`                  | List of receipients keyid                                                                                                                                                       |
| sign                | `bool`                                 | Whether to sign the file                                                                                                                                                        |
| sign_key            | `Option<String>`                       | Keyid to sign the file                                                                                                                                                          |
| symmetric           | `bool`                                 | Whether to encrypt symmetrically  [passphrase must be provided if symmetric is true]                                                                                            |
| symmetric_algo      | `Option<String>`                       | Symmetric algorithm to use [if not provided a highly ranked cipher willl be chosen]                                                                                             |
| always_trust        | `bool`                                 | Whether to always trust keys                                                                                                                                                    |
| passphrase          | `Option<String>`                       | Passphrase to use for symmetric encryption [required if symmetric is true]                                                                                                      |
| output              | `Option<String>`                       | Path to write the encrypted output, will use the default output dir set in GPG if not provided and with file name as [<encryption_type>_encrypted_file_<datetime>.< extension >]|
| extra_args          | `Option<Vec<String>>`                  | Extra arguments to pass to gpg                                                                                                                                                  |

It provided three options to generate the structure type based on your needs:

### `default()`
Encryption with just keys and always trust will be true.  
| parameter           | type                                   | description                                                                                                                                                                     |
|---------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                     |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                    |
| recipients          | `Vec<String>`                          | List of receipients keyid                                                                                                                                                       |
| output              | `Option<String>`                       | Path to write the encrypted output, will use the default output dir set in GPG if not provided and with file name as [<encryption_type>_encrypted_file_<datetime>.< extension >]|

Example:
```rust
use crab_gnupg::gnupg::EncryptOption;

let options: EncryptOption = EncryptOption::default(Some(file), None, vec![" <receipient> ".to_string()], Some(" <OUTPUT> ".to_string()));
```

### `with_symmetric()`
Encryption with passphrase instead of keys and always trust will be true.  
| parameter           | type                                   | description                                                                                                                                                                     |
|---------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                     |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                    |
| symmetric_algo      | `Option<String>`                       | Symmetric algorithm to use [if not provided a highly ranked cipher willl be chosen]                                                                                             |
| passphrase          | `String`                               | Passphrase to use for symmetric encryption [required if symmetric is true]                                                                                                      |
| output              | `Option<String>`                       | Path to write the encrypted output, will use the default output dir set in GPG if not provided and with file name as [<encryption_type>_encrypted_file_<datetime>.< extension >]|

Example:
```rust
use crab_gnupg::gnupg::EncryptOption;

let options: EncryptOption = EncryptOption::with_symmetric(Some(file), None, None, " <PASSPHRASE> ".to_string(), Some(" <OUTPUT> ".to_string()));
```

### `with_key_and_symmetric()`
Encryption with both passphrase and keys and always trust will be true.  
| parameter           | type                                   | description                                                                                                                                                                     |
|---------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                     |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                    |
| recipients          | `Option<Vec<String>>`                  | List of receipients keyid                                                                                                                                                       |
| symmetric_algo      | `Option<String>`                       | Symmetric algorithm to use [if not provided a highly ranked cipher willl be chosen]                                                                                             |
| passphrase          | `String`                               | Passphrase to use for symmetric encryption [required if symmetric is true]                                                                                                      |
| output              | `Option<String>`                       | Path to write the encrypted output, will use the default output dir set in GPG if not provided and with file name as [<encryption_type>_encrypted_file_<datetime>.< extension >]|

Example:
```rust
use crab_gnupg::gnupg::EncryptOption;

let options: EncryptOption = EncryptOption::with_key_and_symmetric(Some(file), None, Some(vec![" <receipient> ".to_string()]), None, " <PASSPHRASE> ".to_string(), Some(" <OUTPUT> ".to_string()));
```

&nbsp;
## DecryptOption
DecryptOption was taken in by `decrypt()` function provided by `GPG`.
| parameter           | type                                   | description                                                                                                                                                                   |
|---------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                   |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                  |
| recipient           | `Option<String>`                       | Receipient keyid                                                                                                                                                              |
| always_trust        | `bool`                                 | Whether to always trust keys                                                                                                                                                  |
| passphrase          | `Option<String>`                       | Passphrase for symmetric encrypted file                                                                                                                                       |
| key_passphrase      | `Option<String>`                       | Passphrase for file that is encrypted using a passphrase protected private key                                                                                                |
| output              | `Option<String>`                       | Path to write the decrypted output, will use the default output dir set in GPG if not provided and with file name as [decrypted_file_<datetime>.< extension >]                |
| extra_args          | `Option<Vec<String>>`                  | Extra arguments to pass to gpg                                                                                                                                                |

It provided two options to generate the structure type based on your needs:

### `default()`
Decryption with secret key and always trust will be true.  
| parameter           | type                                   | description                                                                                                                                                                   |
|---------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                   |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                  |
| recipient           | `String`                               | Receipient keyid                                                                                                                                                              |
| key_passphrase      | `Option<String>`                       | Passphrase for file that is encrypted using a passphrase protected private key                                                                                                |
| output              | `Option<String>`                       | Path to write the decrypted output, will use the default output dir set in GPG if not provided and with file name as [decrypted_file_<datetime>.< extension >]                |

Example:
```rust
use crab_gnupg::gnupg::DecryptOption;

let options: DecryptOption = DecryptOption::default(Some(file), None, " <receipient> ".to_string(), Some(" <KEY_PASSPHRASE> ".to_string()), Some(" <OUTPUT> ".to_string()));
```

### `with_symmetric()`
Decryption with passphrase instead of secret keys and always trust will be true.  
| parameter           | type                                   | description                                                                                                                                                                   |
|---------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                   |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                  |
| passphrase          | `String`                               | Passphrase for symmetric encrypted file                                                                                                                                       |
| output              | `Option<String>`                       | Path to write the decrypted output, will use the default output dir set in GPG if not provided and with file name as [decrypted_file_<datetime>.< extension >]                |

Example:
```rust
use crab_gnupg::gnupg::DecryptOption;

let options: DecryptOption = DecryptOption::with_symmetric(Some(file), None, " <PASSPHRASE> ".to_string(), Some(" <OUTPUT> ".to_string()));
```

&nbsp;
## SignOption
SignOption was taken in by `sign()` function provided by `GPG`.
| parameter           | type                                   | description                                                                                                                                                                          |
|---------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                          |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                         |
| keyid               | `Option<String>`                       | Keyid for signing                                                                                                                                                                    |
| key_passphrase      | `Option<String>`                       | Passphrase for passphrase protected private key                                                                                                                                      |
| clearsign           | `bool`                                 | Whether to use clear signing                                                                                                                                                         |
| detached            | `bool`                                 | Whether to produce a detached signature                                                                                                                                              |
| output              | `Option<String>`                       | Path to write the detached signature or embedded sign file, will use the default output dir set in GPG if not provided and with file name as [<sign_type>_<datetime>.< sig or gpg >] |
| extra_args          | `Option<Vec<String>>`                  | Extra arguments to pass to gpg                                                                                                                                                       |

It provided two options to generate the structure type based on your needs:

### `default()`
Embedded signing with secret key with clearsign.  
| parameter           | type                                   | description                                                                                                                                                                          |
|---------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                          |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                         |
| keyid               | `String`                               | Keyid for signing                                                                                                                                                                    |
| key_passphrase      | `Option<String>`                       | Passphrase for passphrase protected private key                                                                                                                                      |
| output              | `Option<String>`                       | Path to write the detached signature or embedded sign file, will use the default output dir set in GPG if not provided and with file name as [<sign_type>_<datetime>.< sig or gpg >] |

Example:
```rust
use crab_gnupg::gnupg::SignOption;

let options: SignOption = SignOption::default(Some(file), None, " < KEYID > ".to_string(), Some(" <KEY_PASSPHRASE> ".to_string()), Some(" <OUTPUT> ".to_string()));
```

### `detached()`
Detached signing with secret key without clearsign.  
| parameter           | type                                   | description                                                                                                                                                                          |
|---------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file                | `Option<File>`                         | File object                                                                                                                                                                          |
| file_path           | `Option<String>`                       | Path to file                                                                                                                                                                         |
| keyid               | `String`                               | Keyid for signing                                                                                                                                                                    |
| key_passphrase      | `Option<String>`                       | Passphrase for passphrase protected private key                                                                                                                                      |
| output              | `Option<String>`                       | Path to write the detached signature or embedded sign file, will use the default output dir set in GPG if not provided and with file name as [<sign_type>_<datetime>.< sig or gpg >] |

Example:
```rust
use crab_gnupg::gnupg::SignOption;

let options: SignOption = SignOption::detached(Some(file), None, " < KEYID > ".to_string(), Some(" <KEY_PASSPHRASE> ".to_string()), Some(" <OUTPUT> ".to_string()));
```

---
&nbsp;
## TrustLevel
An enum to represent the level of trust for trusting a gpg key. The options are:

- Expired
- Undefined
- Never
- Marginal
- Fully
- Ultimate