Class: CoBreak::Cipher::Base16
- Inherits:
-
Object
- Object
- CoBreak::Cipher::Base16
- Defined in:
- ext/cobreak/cobreak_cipher.c
Class Method Summary collapse
-
.decode(full) ⇒ Object
Terminar correctamente la cadena.
-
.encode(full) ⇒ Object
Agregar el terminador de cadena.
Class Method Details
.decode(full) ⇒ Object
Terminar correctamente la cadena
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'ext/cobreak/cobreak_cipher.c', line 27
VALUE b16_decode(VALUE self, VALUE full) {
char *myb16 = RSTRING_PTR(full);
char strb16[1024];
size_t length = strlen(myb16);
// Validar longitud
if (length % 2 != 0) {
rb_raise(rb_eArgError, "Hex string must have an even length");
}
// Decodificación
decodeblock16(myb16, strb16, length);
return rb_str_new2(strb16);
}
|
.encode(full) ⇒ Object
Agregar el terminador de cadena
51 52 53 54 55 56 57 58 59 |
# File 'ext/cobreak/cobreak_cipher.c', line 51
VALUE b16_encode(VALUE self, VALUE full) {
char *strb16 = RSTRING_PTR(full);
char myb16[1024 * 2 + 1]; // Buffer para la codificación
size_t length = strlen(strb16);
// Codificación
encodeblock16(strb16, length, myb16);
return rb_str_new2(myb16);
}
|