@@ -67,9 +67,9 @@ impl OTPElement {
67
67
}
68
68
69
69
pub fn read_from_file ( ) -> Result < Vec < OTPElement > , String > {
70
- let mut encrypted_contents = read_to_string ( & get_db_path ( ) ) . unwrap ( ) ;
70
+ let encrypted_contents = read_to_string ( & get_db_path ( ) ) . unwrap ( ) ;
71
71
//rust close files at the end of the function
72
- let contents = cryptograpy:: decrypt_string ( & mut encrypted_contents, & cryptograpy:: prompt_for_passwords ( "Password: " ) ) ;
72
+ let contents = cryptograpy:: decrypt_string ( & encrypted_contents, & cryptograpy:: prompt_for_passwords ( "Password: " ) ) ;
73
73
match contents {
74
74
Ok ( contents) => {
75
75
let vector: Vec < OTPElement > = serde_json:: from_str ( & contents) . unwrap ( ) ;
@@ -172,8 +172,8 @@ pub fn export_database() -> Result<String, String> {
172
172
let mut exported_path = utils:: get_home_folder ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
173
173
exported_path. push_str ( "/exported.cotp" ) ;
174
174
let mut file = File :: create ( & exported_path) . expect ( "Cannot create file" ) ;
175
- let mut encrypted_contents = read_to_string ( & get_db_path ( ) ) . unwrap ( ) ;
176
- let contents = cryptograpy:: decrypt_string ( & mut encrypted_contents, & cryptograpy:: prompt_for_passwords ( "Password: " ) ) ;
175
+ let encrypted_contents = read_to_string ( & get_db_path ( ) ) . unwrap ( ) ;
176
+ let contents = cryptograpy:: decrypt_string ( & encrypted_contents, & cryptograpy:: prompt_for_passwords ( "Password: " ) ) ;
177
177
match contents {
178
178
Ok ( contents) => {
179
179
file. write_all ( contents. as_bytes ( ) ) . expect ( "Failed to write contents" ) ;
@@ -191,7 +191,7 @@ pub fn overwrite_database(elements: Vec<OTPElement>){
191
191
}
192
192
193
193
pub fn overwrite_database_json ( json : & str ) {
194
- let encrypted = cryptograpy:: encrypt_string ( & mut json. to_string ( ) , & cryptograpy:: prompt_for_passwords ( "Insert password for database encryption: " ) ) ;
194
+ let encrypted = cryptograpy:: encrypt_string ( json. to_string ( ) , & cryptograpy:: prompt_for_passwords ( "Insert password for database encryption: " ) ) ;
195
195
utils:: write_to_file ( & encrypted, & mut File :: create ( utils:: get_db_path ( ) ) . expect ( "Failed to open file" ) ) ;
196
196
}
197
197
0 commit comments