10
10
-export ([supported_ciphers /0 , supported_hashes /0 , default_cipher /0 , default_hash /0 , default_iterations /0 ]).
11
11
-export ([encrypt_term /5 , decrypt_term /5 ]).
12
12
-export ([encrypt /5 , decrypt /5 ]).
13
+ -export ([encrypt /2 , decrypt /2 ]).
13
14
14
- -export_type ([encryption_result / 0 ]).
15
+ -type encryptable_input () :: iodata () | '$pending-secret' .
16
+
17
+ -export_type ([encryptable_input / 0 , encryption_result / 0 ]).
15
18
16
19
supported_ciphers () ->
17
20
credentials_obfuscation_pbe :supported_ciphers ().
@@ -46,7 +49,7 @@ decrypt_term(Cipher, Hash, Iterations, PassPhrase, {encrypted, _Base64Binary}=En
46
49
-type crypto_hash_algorithm () :: atom ().
47
50
48
51
-spec encrypt (crypto_cipher (), crypto_hash_algorithm (),
49
- pos_integer (), iodata () | '$pending-secret' , binary ()) -> encryption_result ().
52
+ pos_integer (), encryptable_input () , binary ()) -> encryption_result ().
50
53
encrypt (Cipher , Hash , Iterations , PassPhrase , ClearText ) ->
51
54
credentials_obfuscation_pbe :encrypt (Cipher , Hash , Iterations , PassPhrase , ClearText ).
52
55
@@ -57,3 +60,15 @@ decrypt(_Cipher, _Hash, _Iterations, _PassPhrase, {plaintext, Term}) ->
57
60
Term ;
58
61
decrypt (Cipher , Hash , Iterations , PassPhrase , {encrypted , _Base64Binary }= Encrypted ) ->
59
62
credentials_obfuscation_pbe :decrypt (Cipher , Hash , Iterations , PassPhrase , Encrypted ).
63
+
64
+
65
+ -spec encrypt (encryptable_input (), binary ()) -> encryption_result ().
66
+ encrypt (PassPhrase , ClearText ) ->
67
+ credentials_obfuscation_pbe :encrypt (default_cipher (), default_hash (), default_iterations (), PassPhrase , ClearText ).
68
+
69
+
70
+ -spec decrypt (iodata (), encryption_result ()) -> any ().
71
+ decrypt (_PassPhrase , {plaintext , Term }) ->
72
+ Term ;
73
+ decrypt (PassPhrase , {encrypted , _Base64Binary }= Encrypted ) ->
74
+ credentials_obfuscation_pbe :decrypt (default_cipher (), default_hash (), default_iterations (), PassPhrase , Encrypted ).
0 commit comments