++ed by:
HAARG

1 PAUSE user(s)

gray

NAME

Crypt::Scrypt - Perl interface to the scrypt key derivation function

SYNOPSIS

    use Crypt::Scrypt;

    my $scrypt = Crypt::Scrypt->new(
        key          => $key,
        max_mem      => $bytes,
        max_mem_frac => $fraction,
        max_time     => $seconds
    );
    my $ciphertext = $scrypt->encrypt($plaintext);
    my $plaintext  = $scrypt->decrypt($ciphertext);

    # or using class methods:
    my $ciphertext = Crypt::Scrypt->encrypt($plaintext,  key => $key, %args);
    my $plaintext  = Crypt::Scrypt->decrypt($ciphertext, key => $key, %args);

DESCRIPTION

The Crypt::Scrypt module provides an interface to the scrypt key derivation function. It is designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt.

CONSTRUCTOR

new

    $scrypt = Crypt::Scrypt->new(
        key          => $key,
        max_mem      => $bytes,
        max_mem_frac => $fraction,
        max_time     => $seconds
    );
  • key

    The key used to encrypt the plaintext. This parameter is required.

  • max_mem

    The maximum number of bytes of memory to use for computation. If set to 0, no maximum will be enforced; any other value less than 1 MiB will be treated as 1 MiB.

    Defaults to 0.

  • max_mem_frac

    The maximum fraction of available memory to use for computation. If this value is set to 0 or more than 0.5 it will be treated as 0.5; this value will never cause a limit of less than 1 MiB to be enforced.

    Defaults to 0.125.

  • max_time

    The maximum number of seconds of CPU time for computation.

    Defaults to 5 seconds.

When encrypting, the key strength is maximized subject to the specified limits; when decrypting, an error is returned if decrypting the data is not possible within the specified limits.

METHODS

encrypt

    $ciphertext = $scrypt->encrypt($plaintext, %args)

Encrypts the plaintext and returns the ciphertext. The plaintext can be either a scalar or scalar reference. Additional named arguments can override any value provided to the constructor. Croaks on failure.

decrypt

    $plaintext  = $scrypt->decrypt($ciphertext, %args)

Decrypts the ciphertext and and returns the plaintext. The ciphertext can be either a scalar or scalar reference. Additional named arguments can override any value provided to the constructor. Croaks on failure.

SEE ALSO

http://www.tarsnap.com/scrypt.html

http://git.chromium.org/gitweb/?p=chromiumos/third_party/libscrypt.git;a=tree

REQUESTS AND BUGS

Please report any bugs or feature requests to http://rt.cpan.org/Public/Bug/Report.html?Queue=Crypt-Scrypt. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Crypt::Scrypt

You can also look for information at:

COPYRIGHT AND LICENSE

Copyright (C) 2011 gray <gray at cpan.org>, all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

gray, <gray at cpan.org>