Method: Krypt::Base64.decode
- Defined in:
- ext/krypt/core/krypt_b64.c
.Krypt::Base64.decode(data) ⇒ String
Decodes a Base64-encoded string of data, which need not necessarily be a String, but must allow a conversion with to_str.
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'ext/krypt/core/krypt_b64.c', line 308 static VALUE krypt_base64_module_decode(VALUE self, VALUE data) { VALUE ret; size_t len; size_t result_len; uint8_t *bytes; uint8_t *result = NULL; StringValue(data); len = (size_t) RSTRING_LEN(data); bytes = (uint8_t *) RSTRING_PTR(data); if (krypt_base64_decode(bytes, len, &result, &result_len) == KRYPT_ERR) krypt_error_raise(eKryptBase64Error, "Processing the value failed."); ret = rb_str_new((const char *) result, result_len); xfree(result); return ret; } |