Giter Club home page Giter Club logo

crypt3's Introduction

Crypt3

This crate is a clone of the linux crypt command. It is a wrapper for the crypto algorithms used in crypt - Md5, blowfish, SHA256 and SHA512. The algorithm is chosen based on the first 3 characters of the secret. If it starts with $x$ where x is one of 1, 2, 3, 5 or 6.

Till this release (0.1), only MD5($1$), SHA256 ($5$) and SHA512 ($6$) are supported.

SECURITY ALERT:

The package is provided for the purposes of interoperability with protocols and systems that mandate the use of MD5. However, MD5 should be considered cryptographically broken and unsuitable for further use. Collision attacks against MD5 are both practical and trivial, and theoretical attacks against MD5 have been found. RFC6151 advises no new protocols to be designed with any MD5-based constructions, including HMAC-MD5.

INSTALLATION:

To add crypt to your package, add this to your Cargo.toml:

[dependencies]
crypt3 = "0.1"

EXAMPLES:

use crypt3::crypt;

pub fn foo() {
   let digest = crypt(b"abcdefghijklmnop", b"$1$");
}

License

Licensed under either of

at your option.

crypt3's People

Contributors

connectkushal avatar dylan-dpc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crypt3's Issues

Consider using thiserror instead of Box<Error>

I have a main function which returns anyhow::Result<()> and I'm getting the following error when using the ? operator with crypt:

let result = crypt(password.as_bytes(), &user_pwd.pw_passwd.as_bytes())?; 
error[E0277]: the size for values of type `dyn std::error::Error` cannot be known at compilation time
   --> src/bin/passwd.rs:413:76
    |
413 |     let result = crypt(password.as_bytes(), &user_pwd.pw_passwd.as_bytes())?;
    |                                                                            ^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `dyn std::error::Error`
    = help: the following other types implement trait `FromResidual<R>`:
              <Result<T, F> as FromResidual<Yeet<E>>>
              <Result<T, F> as FromResidual<Result<Infallible, E>>>
    = note: required for `Box<dyn std::error::Error>` to implement `std::error::Error`
    = note: required for `anyhow::Error` to implement `From<Box<dyn std::error::Error>>`
    = note: required for `Result<(), anyhow::Error>` to implement `FromResidual<Result<Infallible, Box<dyn std::error::Error>>>`

error[E0277]: `dyn std::error::Error` cannot be sent between threads safely
   --> src/bin/passwd.rs:413:76
    |
413 |     let result = crypt(password.as_bytes(), &user_pwd.pw_passwd.as_bytes())?;
    |                                                                            ^ `dyn std::error::Error` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `dyn std::error::Error`
    = help: the following other types implement trait `FromResidual<R>`:
              <Result<T, F> as FromResidual<Yeet<E>>>
              <Result<T, F> as FromResidual<Result<Infallible, E>>>
    = note: required for `Unique<dyn std::error::Error>` to implement `Send`
note: required because it appears within the type `Box<dyn Error>`
   --> /home/amiculas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:195:12
    |
195 | pub struct Box<
    |            ^^^
    = note: required for `anyhow::Error` to implement `From<Box<dyn std::error::Error>>`
    = note: required for `Result<(), anyhow::Error>` to implement `FromResidual<Result<Infallible, Box<dyn std::error::Error>>>`

error[E0277]: `dyn std::error::Error` cannot be shared between threads safely
   --> src/bin/passwd.rs:413:76
    |
413 |     let result = crypt(password.as_bytes(), &user_pwd.pw_passwd.as_bytes())?;
    |                                                                            ^ `dyn std::error::Error` cannot be shared between threads safely
    |
    = help: the trait `Sync` is not implemented for `dyn std::error::Error`
    = help: the following other types implement trait `FromResidual<R>`:
              <Result<T, F> as FromResidual<Yeet<E>>>
              <Result<T, F> as FromResidual<Result<Infallible, E>>>
    = note: required for `Unique<dyn std::error::Error>` to implement `Sync`
note: required because it appears within the type `Box<dyn Error>`
   --> /home/amiculas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:195:12
    |
195 | pub struct Box<
    |            ^^^
    = note: required for `anyhow::Error` to implement `From<Box<dyn std::error::Error>>`
    = note: required for `Result<(), anyhow::Error>` to implement `FromResidual<Result<Infallible, Box<dyn std::error::Error>>>`

Using an error type derived with thiserror would solve this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.