z85 0.10 → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/z85/z85.c +20 -20
- data/lib/z85/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7e357196aefb2cecd96eacf44ca120034fa9082210055dd7db46fa1b1b05e3e
|
4
|
+
data.tar.gz: 7ef29017f657680b64138a1d163774a12f78cbb7202e324c4eefefbf947ee81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c57c7471bf3e66bee9e6987c280e7355c41ecf213f4e10792790b5a16a0ca27d0e6a6b2621663f767435910c7364faad2f628b0c8de2321a3938dd6549d929bf
|
7
|
+
data.tar.gz: 26714969d363d9f5b4f81d6c4f4754a283b1d4028ed4bfa9dcc5231fe63d95e5d6b1bdd7c4e4de43d1db5a306d6cdbe818a18062c25aa0db30ae36c10f2247bd
|
data/ext/z85/z85.c
CHANGED
@@ -71,18 +71,18 @@ static VALUE z85_encode(VALUE _mod, VALUE string)
|
|
71
71
|
char* encoded = xmalloc(encoded_len + 1);
|
72
72
|
uint char_nbr = 0;
|
73
73
|
uint byte_nbr = 0;
|
74
|
-
uint32_t value = 0;
|
75
74
|
|
76
75
|
while (byte_nbr < size) {
|
77
|
-
value =
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
76
|
+
uint32_t value = 0;
|
77
|
+
|
78
|
+
for (int i = 0; i < 4; i++)
|
79
|
+
value = value*256 + data[byte_nbr++];
|
80
|
+
|
81
|
+
encoded[char_nbr++] = encoder[value/(85*85*85*85) % 85];
|
82
|
+
encoded[char_nbr++] = encoder[value/(85*85*85) % 85];
|
83
|
+
encoded[char_nbr++] = encoder[value/(85*85) % 85];
|
84
|
+
encoded[char_nbr++] = encoder[value/85 % 85];
|
85
|
+
encoded[char_nbr++] = encoder[value % 85];
|
86
86
|
}
|
87
87
|
encoded[char_nbr] = 0;
|
88
88
|
|
@@ -103,17 +103,17 @@ static VALUE z85_decode(VALUE _mod, VALUE rstring)
|
|
103
103
|
|
104
104
|
uint byte_nbr = 0;
|
105
105
|
uint char_nbr = 0;
|
106
|
-
|
106
|
+
|
107
107
|
while (char_nbr < strlen) {
|
108
|
-
value =
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
108
|
+
uint32_t value = 0;
|
109
|
+
|
110
|
+
for (int i = 0; i < 5; i++)
|
111
|
+
value = value*85 + decoder[(byte) string[char_nbr++] - 32];
|
112
|
+
|
113
|
+
decoded[byte_nbr++] = value/(256*256*256) % 256;
|
114
|
+
decoded[byte_nbr++] = value/(256*256) % 256;
|
115
|
+
decoded[byte_nbr++] = value/256 % 256;
|
116
|
+
decoded[byte_nbr++] = value % 256;
|
117
117
|
}
|
118
118
|
|
119
119
|
VALUE out = rb_str_new((const char*) decoded, decoded_size);
|
data/lib/z85/version.rb
CHANGED