rubysl-digest 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.travis.yml +7 -0
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/ext/rubysl/digest/bubblebabble/.gitignore +2 -0
- data/ext/rubysl/digest/bubblebabble/bubblebabble.c +147 -0
- data/ext/rubysl/digest/bubblebabble/bubblebabble.h +2 -0
- data/ext/rubysl/digest/bubblebabble/depend +3 -0
- data/ext/rubysl/digest/bubblebabble/extconf.h +4 -0
- data/ext/rubysl/digest/bubblebabble/extconf.rb +6 -0
- data/ext/rubysl/digest/defs.h +19 -0
- data/ext/rubysl/digest/digest.c +660 -0
- data/ext/rubysl/digest/digest.h +32 -0
- data/ext/rubysl/digest/extconf.rb +10 -0
- data/ext/rubysl/digest/md5/.gitignore +2 -0
- data/ext/rubysl/digest/md5/extconf.rb +29 -0
- data/ext/rubysl/digest/md5/md5.c +422 -0
- data/ext/rubysl/digest/md5/md5.h +80 -0
- data/ext/rubysl/digest/md5/md5init.c +40 -0
- data/ext/rubysl/digest/md5/md5ossl.c +9 -0
- data/ext/rubysl/digest/md5/md5ossl.h +13 -0
- data/ext/rubysl/digest/rmd160/.gitignore +2 -0
- data/ext/rubysl/digest/rmd160/extconf.rb +28 -0
- data/ext/rubysl/digest/rmd160/rmd160.c +457 -0
- data/ext/rubysl/digest/rmd160/rmd160.h +56 -0
- data/ext/rubysl/digest/rmd160/rmd160init.c +40 -0
- data/ext/rubysl/digest/rmd160/rmd160ossl.c +8 -0
- data/ext/rubysl/digest/rmd160/rmd160ossl.h +19 -0
- data/ext/rubysl/digest/sha1/.gitignore +2 -0
- data/ext/rubysl/digest/sha1/extconf.rb +28 -0
- data/ext/rubysl/digest/sha1/sha1.c +269 -0
- data/ext/rubysl/digest/sha1/sha1.h +39 -0
- data/ext/rubysl/digest/sha1/sha1init.c +40 -0
- data/ext/rubysl/digest/sha1/sha1ossl.c +10 -0
- data/ext/rubysl/digest/sha1/sha1ossl.h +20 -0
- data/ext/rubysl/digest/sha2/.gitignore +2 -0
- data/ext/rubysl/digest/sha2/extconf.rb +24 -0
- data/ext/rubysl/digest/sha2/sha2.c +919 -0
- data/ext/rubysl/digest/sha2/sha2.h +109 -0
- data/ext/rubysl/digest/sha2/sha2init.c +52 -0
- data/lib/digest/bubblebabble.rb +1 -0
- data/lib/digest/hmac.rb +302 -0
- data/lib/digest/md5.rb +23 -0
- data/lib/digest/rmd160.rb +1 -0
- data/lib/digest/sha1.rb +23 -0
- data/lib/digest/sha2.rb +74 -0
- data/lib/digest.rb +1 -0
- data/lib/rubysl/digest/digest.rb +88 -0
- data/lib/{rubysl-digest → rubysl/digest}/version.rb +1 -1
- data/lib/rubysl/digest.rb +2 -0
- data/rubysl-digest.gemspec +25 -17
- data/spec/hexencode_spec.rb +30 -0
- data/spec/md5/append_spec.rb +6 -0
- data/spec/md5/block_length_spec.rb +11 -0
- data/spec/md5/digest_bang_spec.rb +12 -0
- data/spec/md5/digest_length_spec.rb +11 -0
- data/spec/md5/digest_spec.rb +31 -0
- data/spec/md5/equal_spec.rb +37 -0
- data/spec/md5/file_spec.rb +42 -0
- data/spec/md5/hexdigest_bang_spec.rb +13 -0
- data/spec/md5/hexdigest_spec.rb +31 -0
- data/spec/md5/inspect_spec.rb +11 -0
- data/spec/md5/length_spec.rb +7 -0
- data/spec/md5/reset_spec.rb +14 -0
- data/spec/md5/shared/constants.rb +16 -0
- data/spec/md5/shared/length.rb +8 -0
- data/spec/md5/shared/sample.rb +15 -0
- data/spec/md5/shared/update.rb +7 -0
- data/spec/md5/size_spec.rb +7 -0
- data/spec/md5/to_s_spec.rb +21 -0
- data/spec/md5/update_spec.rb +6 -0
- data/spec/sha1/digest_spec.rb +19 -0
- data/spec/sha1/file_spec.rb +42 -0
- data/spec/sha1/shared/constants.rb +16 -0
- data/spec/sha256/append_spec.rb +6 -0
- data/spec/sha256/block_length_spec.rb +11 -0
- data/spec/sha256/digest_bang_spec.rb +12 -0
- data/spec/sha256/digest_length_spec.rb +11 -0
- data/spec/sha256/digest_spec.rb +31 -0
- data/spec/sha256/equal_spec.rb +36 -0
- data/spec/sha256/file_spec.rb +42 -0
- data/spec/sha256/hexdigest_bang_spec.rb +13 -0
- data/spec/sha256/hexdigest_spec.rb +31 -0
- data/spec/sha256/inspect_spec.rb +11 -0
- data/spec/sha256/length_spec.rb +7 -0
- data/spec/sha256/reset_spec.rb +14 -0
- data/spec/sha256/shared/constants.rb +16 -0
- data/spec/sha256/shared/length.rb +8 -0
- data/spec/sha256/shared/update.rb +7 -0
- data/spec/sha256/size_spec.rb +7 -0
- data/spec/sha256/to_s_spec.rb +20 -0
- data/spec/sha256/update_spec.rb +6 -0
- data/spec/sha384/append_spec.rb +6 -0
- data/spec/sha384/block_length_spec.rb +11 -0
- data/spec/sha384/digest_bang_spec.rb +12 -0
- data/spec/sha384/digest_length_spec.rb +11 -0
- data/spec/sha384/digest_spec.rb +31 -0
- data/spec/sha384/equal_spec.rb +36 -0
- data/spec/sha384/file_spec.rb +42 -0
- data/spec/sha384/hexdigest_bang_spec.rb +13 -0
- data/spec/sha384/hexdigest_spec.rb +31 -0
- data/spec/sha384/inspect_spec.rb +11 -0
- data/spec/sha384/length_spec.rb +7 -0
- data/spec/sha384/reset_spec.rb +14 -0
- data/spec/sha384/shared/constants.rb +17 -0
- data/spec/sha384/shared/length.rb +8 -0
- data/spec/sha384/shared/update.rb +7 -0
- data/spec/sha384/size_spec.rb +7 -0
- data/spec/sha384/to_s_spec.rb +20 -0
- data/spec/sha384/update_spec.rb +6 -0
- data/spec/sha512/append_spec.rb +6 -0
- data/spec/sha512/block_length_spec.rb +11 -0
- data/spec/sha512/digest_bang_spec.rb +12 -0
- data/spec/sha512/digest_length_spec.rb +11 -0
- data/spec/sha512/digest_spec.rb +31 -0
- data/spec/sha512/equal_spec.rb +36 -0
- data/spec/sha512/file_spec.rb +42 -0
- data/spec/sha512/hexdigest_bang_spec.rb +13 -0
- data/spec/sha512/hexdigest_spec.rb +31 -0
- data/spec/sha512/inspect_spec.rb +11 -0
- data/spec/sha512/length_spec.rb +7 -0
- data/spec/sha512/reset_spec.rb +14 -0
- data/spec/sha512/shared/constants.rb +16 -0
- data/spec/sha512/shared/length.rb +8 -0
- data/spec/sha512/shared/update.rb +7 -0
- data/spec/sha512/size_spec.rb +7 -0
- data/spec/sha512/to_s_spec.rb +20 -0
- data/spec/sha512/update_spec.rb +6 -0
- metadata +283 -88
- data/lib/rubysl-digest.rb +0 -7
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c09921afabe5d9ba60b1b2edf93b0fb9d14ae96
|
4
|
+
data.tar.gz: bd40f84232d0c97ec00e63028716f1c365b98e78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8dfd971aa37c3411f7fb6194b8dfb3e5ff8fe0f834a48b64d522fd74075281517b3a54893ef027289b9b520152ba8d841c1c704e27d299829f9e5e64cdc4da2
|
7
|
+
data.tar.gz: 1b8c0514abf04b64676ed03e154cca8694f94f9fa193feb86cce5133893fd44adac877668f8171183ca4db9b7a93134cebbd1eabdb9e9d08dbf0873033e1f11e
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Rubysl::Digest
|
2
2
|
|
3
3
|
TODO: Write a gem description
|
4
4
|
|
@@ -24,6 +24,6 @@ TODO: Write usage instructions here
|
|
24
24
|
|
25
25
|
1. Fork it
|
26
26
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am '
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
29
|
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -0,0 +1,147 @@
|
|
1
|
+
/************************************************
|
2
|
+
|
3
|
+
bubblebabble.c - BubbleBabble encoding support
|
4
|
+
|
5
|
+
$Author: shyouhei $
|
6
|
+
created at: Fri Oct 13 18:31:42 JST 2006
|
7
|
+
|
8
|
+
Copyright (C) 2006 Akinori MUSHA
|
9
|
+
|
10
|
+
$Id: bubblebabble.c 11708 2007-02-12 23:01:19Z shyouhei $
|
11
|
+
|
12
|
+
************************************************/
|
13
|
+
|
14
|
+
#include "bubblebabble.h"
|
15
|
+
|
16
|
+
static ID id_digest;
|
17
|
+
|
18
|
+
static VALUE
|
19
|
+
bubblebabble_str_new(VALUE str_digest)
|
20
|
+
{
|
21
|
+
char *digest;
|
22
|
+
size_t digest_len;
|
23
|
+
VALUE str;
|
24
|
+
char *p;
|
25
|
+
char *buf;
|
26
|
+
int buf_len;
|
27
|
+
int i, j, seed = 1;
|
28
|
+
static const char vowels[] = {
|
29
|
+
'a', 'e', 'i', 'o', 'u', 'y'
|
30
|
+
};
|
31
|
+
static const char consonants[] = {
|
32
|
+
'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', 'n',
|
33
|
+
'p', 'r', 's', 't', 'v', 'z', 'x'
|
34
|
+
};
|
35
|
+
|
36
|
+
StringValue(str_digest);
|
37
|
+
digest_len = RSTRING_LEN(str_digest);
|
38
|
+
|
39
|
+
if ((LONG_MAX - 2) / 3 < (digest_len | 1)) {
|
40
|
+
rb_raise(rb_eRuntimeError, "digest string too long");
|
41
|
+
}
|
42
|
+
|
43
|
+
digest = rb_str_ptr_readonly(str_digest);
|
44
|
+
buf_len = (digest_len | 1) * 3 + 2;
|
45
|
+
buf = calloc(buf_len, sizeof(char));
|
46
|
+
p = buf;
|
47
|
+
|
48
|
+
i = j = 0;
|
49
|
+
p[j++] = 'x';
|
50
|
+
|
51
|
+
for (;;) {
|
52
|
+
unsigned char byte1, byte2;
|
53
|
+
|
54
|
+
if (i >= digest_len) {
|
55
|
+
p[j++] = vowels[seed % 6];
|
56
|
+
p[j++] = consonants[16];
|
57
|
+
p[j++] = vowels[seed / 6];
|
58
|
+
break;
|
59
|
+
}
|
60
|
+
|
61
|
+
byte1 = digest[i++];
|
62
|
+
p[j++] = vowels[(((byte1 >> 6) & 3) + seed) % 6];
|
63
|
+
p[j++] = consonants[(byte1 >> 2) & 15];
|
64
|
+
p[j++] = vowels[((byte1 & 3) + (seed / 6)) % 6];
|
65
|
+
|
66
|
+
if (i >= digest_len) {
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
|
70
|
+
byte2 = digest[i++];
|
71
|
+
p[j++] = consonants[(byte2 >> 4) & 15];
|
72
|
+
p[j++] = '-';
|
73
|
+
p[j++] = consonants[byte2 & 15];
|
74
|
+
|
75
|
+
seed = (seed * 5 + byte1 * 7 + byte2) % 36;
|
76
|
+
}
|
77
|
+
|
78
|
+
p[j] = 'x';
|
79
|
+
|
80
|
+
str = rb_str_new(buf, buf_len);
|
81
|
+
free(buf);
|
82
|
+
|
83
|
+
return str;
|
84
|
+
}
|
85
|
+
|
86
|
+
/*
|
87
|
+
* call-seq:
|
88
|
+
* Digest.bubblebabble(string) -> bubblebabble_string
|
89
|
+
*
|
90
|
+
* Returns a BubbleBabble encoded version of a given _string_.
|
91
|
+
*/
|
92
|
+
static VALUE
|
93
|
+
rb_digest_s_bubblebabble(VALUE klass, VALUE str)
|
94
|
+
{
|
95
|
+
return bubblebabble_str_new(str);
|
96
|
+
}
|
97
|
+
|
98
|
+
/*
|
99
|
+
* call-seq:
|
100
|
+
* Digest::Class.bubblebabble(string, ...) -> hash_string
|
101
|
+
*
|
102
|
+
* Returns the BubbleBabble encoded hash value of a given _string_.
|
103
|
+
*/
|
104
|
+
static VALUE
|
105
|
+
rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass)
|
106
|
+
{
|
107
|
+
return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv));
|
108
|
+
}
|
109
|
+
|
110
|
+
/*
|
111
|
+
* call-seq:
|
112
|
+
* digest_obj.bubblebabble -> hash_string
|
113
|
+
*
|
114
|
+
* Returns the resulting hash value in a Bubblebabble encoded form.
|
115
|
+
*/
|
116
|
+
static VALUE
|
117
|
+
rb_digest_instance_bubblebabble(VALUE self)
|
118
|
+
{
|
119
|
+
return bubblebabble_str_new(rb_funcall(self, id_digest, 0));
|
120
|
+
}
|
121
|
+
|
122
|
+
/*
|
123
|
+
* This module adds some methods to Digest classes to perform
|
124
|
+
* BubbleBabble encoding.
|
125
|
+
*/
|
126
|
+
void
|
127
|
+
Init_bubblebabble(void)
|
128
|
+
{
|
129
|
+
VALUE mDigest, mDigest_Instance, cDigest_Class;
|
130
|
+
|
131
|
+
rb_require("digest");
|
132
|
+
|
133
|
+
mDigest = rb_path2class("Digest");
|
134
|
+
mDigest_Instance = rb_path2class("Digest::Instance");
|
135
|
+
cDigest_Class = rb_path2class("Digest::Class");
|
136
|
+
|
137
|
+
/* Digest::bubblebabble() */
|
138
|
+
rb_define_module_function(mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
|
139
|
+
|
140
|
+
/* Digest::Class::bubblebabble() */
|
141
|
+
rb_define_singleton_method(cDigest_Class, "bubblebabble", rb_digest_class_s_bubblebabble, -1);
|
142
|
+
|
143
|
+
/* Digest::Instance#bubblebabble() */
|
144
|
+
rb_define_method(mDigest_Instance, "bubblebabble", rb_digest_instance_bubblebabble, 0);
|
145
|
+
|
146
|
+
id_digest = rb_intern("digest");
|
147
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/* -*- C -*-
|
2
|
+
* $Id: defs.h 15780 2008-03-14 08:04:45Z nobu $
|
3
|
+
*/
|
4
|
+
|
5
|
+
#ifndef DEFS_H
|
6
|
+
#define DEFS_H
|
7
|
+
|
8
|
+
#include "ruby.h"
|
9
|
+
#include <sys/types.h>
|
10
|
+
|
11
|
+
#if defined(HAVE_SYS_CDEFS_H)
|
12
|
+
# include <sys/cdefs.h>
|
13
|
+
#endif
|
14
|
+
#if !defined(__BEGIN_DECLS)
|
15
|
+
# define __BEGIN_DECLS
|
16
|
+
# define __END_DECLS
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#endif /* DEFS_H */
|