Class: CoBreak::Cipher::Binary
- Inherits:
-
Object
- Object
- CoBreak::Cipher::Binary
- Defined in:
- ext/cobreak/cobreak_cipher.c
Class Method Summary collapse
- .decode(full) ⇒ Object
-
.encode(full) ⇒ Object
Define method for class Binary.
Class Method Details
.decode(full) ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'ext/cobreak/cobreak_cipher.c', line 290
VALUE binary_decode(VALUE self, VALUE full) {
char *mybinary = RSTRING_PTR(full);
char strb[1024];
size_t length = strlen(mybinary);
if (length % 8 != 0) {
rb_raise(rb_eArgError, "Binary string must have a length that is a multiple of 8");
}
decodeblock_binary(mybinary, strb, length);
return rb_str_new2(strb);
}
|
.encode(full) ⇒ Object
Define method for class Binary
280 281 282 283 284 285 286 287 |
# File 'ext/cobreak/cobreak_cipher.c', line 280
VALUE binary_encode(VALUE self, VALUE full) {
char *strb = RSTRING_PTR(full);
char mybinary[1024 * 8 + 1];
size_t length = strlen(strb);
encodeblock_binary(strb, mybinary, length);
return rb_str_new2(mybinary);
}
|