IO_METHOD(IoSandbox, doSandboxString) { /*doc Sandbox doSandboxString(aString) Evaluate aString inside the Sandbox. */ IoState *boxState = IoSandbox_boxState(self); char *s = IoMessage_locals_cStringArgAt_(m, locals, 0); IoObject *result = IoState_doSandboxCString_(boxState, s); if (ISSYMBOL(result)) { return IOSYMBOL(CSTRING(result)); } if (ISSEQ(result)) { return IOSEQ(IOSEQ_BYTES(result), IOSEQ_LENGTH(result)); } if (ISNUMBER(result)) { return IONUMBER(CNUMBER(result)); } return IONIL(self); }
IoObject *IoSHA1_hmac(IoSHA1 *self, IoObject *locals, IoMessage *m) { /*doc SHA1 hmac(key, data) Returns a hmac signature sequence or nil on error. */ IoSeq *key = IoMessage_locals_seqArgAt_(m, locals, 0); IoSeq *inSeq = IoMessage_locals_seqArgAt_(m, locals, 1); char resbuf[20]; int ok; memset(resbuf, 0x0, 20); ok = hmac_sha1( IOSEQ_BYTES(key), IOSEQ_LENGTH(key), IOSEQ_BYTES(inSeq), IOSEQ_LENGTH(inSeq), (void *)resbuf); if(ok != 0) return IONIL(self); return IOSEQ(resbuf, 20); }