0

I am trying to use RustCrypto to instantiate a blowfish object. The new method is implemented by the BlockCipherVarKey trait in the block-cipher-trait crate.

Here is my minimal example:

extern crate block_cipher_trait;
use block_cipher_trait::BlockCipherVarKey;

extern crate blowfish;
use blowfish::Blowfish;

fn main() {
    let key = Vec::new();
    Blowfish::new(key)
}

With the following Cargo.toml:

[dependencies]
blowfish = "0.2.1"
block-cipher-trait = "0.3.0"

I try to build that, but I have the following error:

error: no associated item named `new` found for type `blowfish::Blowfish` in the current scope
 --> src/main.rs:9:5
  |
9 |     Blowfish::new(key)
  |     ^^^^^^^^^^^^^
  |
  = note: the method `new` exists but the following trait bounds were not satisfied: `blowfish::Blowfish : block_cipher_trait::BlockCipherFixKey`, `&blowfish::Blowfish : block_cipher_trait::BlockCipherFixKey`, `&mut blowfish::Blowfish : block_cipher_trait::BlockCipherFixKey`
  = help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
  = help: candidate #1: `use block_cipher_trait::BlockCipherVarKey;`

Why is the use block_cipher_trait::BlockCipherVarKey on line 2 not taken into account? Why does the compiler suggest that I add it although it is already here?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Bromind
  • 1,065
  • 8
  • 23
  • FWIW, it also needs to be `Blowfish::new(&key);`. – Shepmaster Jul 05 '17 at 21:15
  • Thanks @Shepmaster, it is indeed a duplicate, which I didn't found beforehand. concerning the &key, thanks again, but I didn't even arrive to that point before asking ! – Bromind Jul 05 '17 at 21:44
  • Yeah, this particular duplicate is pretty tricky to find. There is work coming to help make it easier to detect and harder to accidentally fall into. – Shepmaster Jul 05 '17 at 21:46

0 Answers0