Crypt-Scrypt

 view release on metacpan or  search on metacpan

Scrypt.xs  view on Meta::CPAN

_encrypt (in, key, max_mem, max_mem_frac, max_time)
    SV *in
    SV *key
    size_t max_mem
    double max_mem_frac
    double max_time
PREINIT:
    char *in_str, *key_str, *out_str;
    STRLEN in_len, key_len;
    int status;
PPCODE:
    if (SvROK(in)) in = SvRV(in);
    in_str = SvPVbyte(in, in_len);
    key_str = SvPVbyte(key, key_len);
    Newx(out_str, 128 + in_len, char);
    status = scryptenc_buf((const uint8_t *)in_str, in_len,
                           (uint8_t *)out_str,
                           (const uint8_t *)key_str, key_len,
                           max_mem, max_mem_frac, max_time);
    EXTEND(SP, 2);
    PUSHs(sv_2mortal(newSViv(status)));

Scrypt.xs  view on Meta::CPAN

_decrypt (in, key, max_mem, max_mem_frac, max_time)
    SV *in
    SV *key
    size_t max_mem
    double max_mem_frac
    double max_time
PREINIT:
    char *in_str, *key_str, *out_str;
    STRLEN in_len, key_len, out_len;
    int status;
PPCODE:
    if (SvROK(in)) in = SvRV(in);
    in_str = SvPVbyte(in, in_len);
    key_str = SvPVbyte(key, key_len);
    Newx(out_str, in_len - 128, char);
    status = scryptdec_buf((const uint8_t *)in_str, in_len,
                           (uint8_t *)out_str, &out_len,
                           (const uint8_t *)key_str, key_len,
                           max_mem, max_mem_frac, max_time);
    EXTEND(SP, 2);
    PUSHs(sv_2mortal(newSViv(status)));



( run in 1.055 second using v1.01-cache-2.11-cpan-71847e10f99 )