safe_crypto build failing for url error => ?workaround

So, playing around to learn…
Looking for a simple way to encrypt/decrypt and low and behold fall over into safe_crypto

but on the simplest of builds I get an error from crate url
… is there a way to workaround this?
… I tried calling on an earlier version in Cargo.toml but it seems not to notice and then I get this…

   Compiling url v1.5.1
error[E0713]: borrow may still be in use when destructor runs
   --> /home/safe/.cargo/registry/src/
249 | impl<'a> Target for ::UrlQuery<'a> {
    |      -- lifetime `'a` defined here
250 |     fn as_mut_string(&mut self) -> &mut String { &mut self.url.serialization }
251 |     fn finish(self) -> &'a mut ::Url { self.url }
    |                                        ^^^^^^^^ - here, drop of `self` needs exclusive access to `*self.url`, because the type `UrlQuery<'_>` implements the `Drop` trait
    |                                        |
    |                                        returning this value requires that `*self.url` is borrowed for `'a`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0713`.
error: could not compile `url`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Just a quick thought, did you update Cargo/Rust to latest versions?

Yes… have now but no change.

The oddity is that compiling just url shows it on v2.2.2 and that works ok… so, I don’t know if it’s forced from this crate… as the error follows trying to compile 1.5.1.

safe_crypto is in maidsafe archive… which has me cycle back to a wonder about how we know what is the latest greatest in a genre and what is old and dated.

Still, I wonder there’s a query about dependencies and handling of those… if we pin the code to certain versions, then bug fixes and useful improvements are missed; if not, there is risk of a break or a surprise… and so many dependencies on the code of course.

It’s unfortunate this is in archive as it looked the best option for what is available for actioning encrypt decrypt on messages. With padding as a file the basic_encryptor from self_encryption works… but it’s not quite the same.

Cargo.toml is just pulling against safe_crypto is simply:
extern crate safe_crypto;

use safe_crypto::*;

fn main () {

let symmetrickey: SymmetricKey = SymmetricKey::new(); // create symmetric key
let symmetrickey_bytes = SymmetricKey.into_bytes(); // for saving

let message = "This is a test."; // before
let message_encrypted = SymmetricKey.encrypt(symmetrickey, &message); // during
let message_decrypted = SymmetricKey.decrypt(symmetrickey, &message_encrypted); // after

println!("symmetrickey: {:?}", &symmetrickey);
println!("symmetrickey_bytes: {:?}", &symmetrickey_bytes);
println!("message: {:?}", &message);
println!("message_encrypted: {:?}", &message_encrypted);
println!("message_decrypted: {:?}", &message_decrypted);


I wonder I’ll have what I need from blsttc example instead. :+1:

1 Like

This topic was automatically closed after 60 days. New replies are no longer allowed.