/* * call-seq: * str.crypt(other_str) => new_str * * Applies a one-way cryptographic hash to <i>str</i> by invoking the standard * library function <code>crypt</code>. The argument is the salt string, which * should be two characters long, each character drawn from * <code>[a-zA-Z0-9./]</code>. */ static VALUE rb_str_crypt(str, salt) VALUE str, salt; { extern char *crypt(); VALUE result; char *s; StringValue(salt); if (RSTRING(salt)->len < 2) rb_raise(rb_eArgError, "salt too short(need >=2 bytes)"); if (RSTRING(str)->ptr) s = RSTRING(str)->ptr; else s = ""; result = rb_str_new2(crypt(s, RSTRING(salt)->ptr)); OBJ_INFECT(result, str); OBJ_INFECT(result, salt); return result; }