pub fn scrypt_simple(password: &str, params: &ScryptParams) -> IoResult<String> {
    let mut rng = try!(OsRng::new());

    // 128-bit salt
    let salt: Vec<u8> = rng.gen_iter::<u8>().take(16).collect();

    // 256-bit derived key
    let mut dk = [0u8, ..32];

    scrypt(password.as_bytes(), salt.as_slice(), params, dk);

    let mut result = "$rscrypt$".into_string();
    if params.r < 256 && params.p < 256 {
        result.push_str("0$");
        let mut tmp = [0u8, ..3];
        tmp[0] = params.log_n;
        tmp[1] = params.r as u8;
        tmp[2] = params.p as u8;
        result.push_str(tmp.to_base64(base64::STANDARD).as_slice());
    } else {
        result.push_str("1$");
        let mut tmp = [0u8, ..9];
        tmp[0] = params.log_n;
        write_u32_le(tmp.mut_slice(1, 5), params.r);
        write_u32_le(tmp.mut_slice(5, 9), params.p);
        result.push_str(tmp.to_base64(base64::STANDARD).as_slice());
    }
    result.push_char('$');
    result.push_str(salt.as_slice().to_base64(base64::STANDARD).as_slice());
    result.push_char('$');
    result.push_str(dk.to_base64(base64::STANDARD).as_slice());
    result.push_char('$');

    return Ok(result);
}
/**
 * scrypt_simple is a helper function that should be sufficient for the majority of cases where
 * an application needs to use Scrypt to hash a password for storage. The result is a String that
 * contains the parameters used as part of its encoding. The scrypt_check function may be used on
 * a password to check if it is equal to a hashed value.
 *
 * # Format
 *
 * The format of the output is a modified version of the Modular Crypt Format that encodes algorithm
 * used and the parameter values. If all parameter values can each fit within a single byte, a
 * compact format is used (format 0). However, if any value cannot, an expanded format where the r
 * and p parameters are encoded using 4 bytes (format 1) is used. Both formats use a 128-bit salt
 * and a 256-bit hash. The format is indicated as "rscrypt" which is short for "Rust Scrypt format."
 *
 * $rscrypt$<format>$<base64(log_n,r,p)>$<base64(salt)>$<based64(hash)>$
 *
 * # Arguments
 *
 * * password - The password to process as a str
 * * params - The ScryptParams to use
 *
 */
scrypt_simple is a helper function that should be sufficient for the majority of cases where
an application needs to use Scrypt to hash a password for storage. The result is a String that
contains the parameters used as part of its encoding. The scrypt_check function may be used on
a password to check if it is equal to a hashed value.

# Format

The format of the output is a modified version of the Modular Crypt Format that encodes algorithm
used and the parameter values. If all parameter values can each fit within a single byte, a
compact format is used (format 0). However, if any value cannot, an expanded format where the r
and p parameters are encoded using 4 bytes (format 1) is used. Both formats use a 128-bit salt
and a 256-bit hash. The format is indicated as "rscrypt" which is short for "Rust Scrypt format."



# Arguments

The password to process as a str
params - The ScryptParams to use
scrypt_simple is a helper function that should be sufficient for the majority of cases where an application needs to use Scrypt to hash a password for storage . The result is a String that contains the parameters used as part of its encoding . The scrypt_check function may be used on a password to check if it is equal to a hashed value . # Format The format of the output is a modified version of the Modular Crypt Format that encodes algorithm used and the parameter values . If all parameter values can each fit within a single byte a compact format is used ( format 0 ) . However if any value cannot an expanded format where the r and p parameters are encoded using 4 bytes ( format 1 ) is used . Both formats use a 128 - bit salt and a 256 - bit hash . The format is indicated as " rscrypt " which is short for " Rust Scrypt format . " # Arguments The password to process as a str params - The ScryptParams to use
pub fn scrypt_simple(password: &str, params: &ScryptParams) -> IoResult<String> {
    let mut rng = try!(OsRng::new());
    // 128-bit salt
    let salt: Vec<u8> = rng.gen_iter::<u8>().take(16).collect();
    // 256-bit derived key
    let mut dk = [0u8, ..32];
    scrypt(password.as_bytes(), salt.as_slice(), params, dk);
    let mut result = "$rscrypt$".into_string();
    if params.r < 256 && params.p < 256 {
        result.push_str("0$");
        let mut tmp = [0u8, ..3];
        tmp[0] = params.log_n;
        tmp[1] = params.r as u8;
        tmp[2] = params.p as u8;
        result.push_str(tmp.to_base64(base64::STANDARD).as_slice());
    } else {
        result.push_str("1$");
        let mut tmp = [0u8, ..9];
        tmp[0] = params.log_n;
        write_u32_le(tmp.mut_slice(1, 5), params.r);
        write_u32_le(tmp.mut_slice(5, 9), params.p);
        result.push_str(tmp.to_base64(base64::STANDARD).as_slice());
    }
    result.push_char('$');
    result.push_str(salt.as_slice().to_base64(base64::STANDARD).as_slice());
    result.push_char('$');
    result.push_str(dk.to_base64(base64::STANDARD).as_slice());
    result.push_char('$');
    return Ok(result);
}
pub fn scrypt_simple ( password : & str , params : & ScryptParams ) -> IoResult < String > { let mut rng = try ! ( OsRng new ( ) ) ; // 128-bit salt let salt : Vec < u8 > = rng . gen_iter :: < u8 > ( ) . take ( 16 ) . collect ( ) ; // 256-bit derived key let mut dk = [ 0u8 , .. 32 ] ; scrypt ( password . as_bytes ( ) , salt . as_slice ( ) , params , dk ) ; let mut result = " " . into_string ( ) ; if params . r < 256 && params . p < 256 { result . push_str ( " " ) ; let mut tmp = [ 0u8 , .. 3 ] ; tmp [ 0 ] = params . log_n ; tmp [ 1 ] = params . r as u8 ; tmp [ 2 ] = params . p as u8 ; result . push_str ( tmp . to_base64 ( base64 :: STANDARD ) . as_slice ( ) ) ; } else { result . push_str ( " " ) ; let mut tmp = [ 0u8 , .. 9 ] ; tmp [ 0 ] = params . log_n ; write_u32_le ( tmp . mut_slice ( 1 , 5 ) , params . r ) ; write_u32_le ( tmp . mut_slice ( 5 , 9 ) , params . p ) ; result . push_str ( tmp . to_base64 ( base64 :: STANDARD ) . as_slice ( ) ) ; } result . push_char ( '$' ) ; result . push_str ( salt . as_slice ( ) . to_base64 ( base64 :: STANDARD ) . as_slice ( ) ) ; result . push_char ( '$' ) ; result . push_str ( dk . to_base64 ( base64 :: STANDARD ) . as_slice ( ) ) ; result . push_char ( '$' ) ; return Ok ( result ) ; }
scrypt_simple is a helper function that should be sufficient for the majority of cases where
 an application needs to use Scrypt to hash a password for storage.
scrypt_simple is a helper function that should be sufficient for the majority of cases where an application needs to use Scrypt to hash a password for storage .
password
&str
params
&ScryptParams
password
&str
params
&ScryptParams