rubysl-digest 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +0 -1
  3. data/.travis.yml +7 -0
  4. data/README.md +2 -2
  5. data/Rakefile +0 -1
  6. data/ext/rubysl/digest/bubblebabble/.gitignore +2 -0
  7. data/ext/rubysl/digest/bubblebabble/bubblebabble.c +147 -0
  8. data/ext/rubysl/digest/bubblebabble/bubblebabble.h +2 -0
  9. data/ext/rubysl/digest/bubblebabble/depend +3 -0
  10. data/ext/rubysl/digest/bubblebabble/extconf.h +4 -0
  11. data/ext/rubysl/digest/bubblebabble/extconf.rb +6 -0
  12. data/ext/rubysl/digest/defs.h +19 -0
  13. data/ext/rubysl/digest/digest.c +660 -0
  14. data/ext/rubysl/digest/digest.h +32 -0
  15. data/ext/rubysl/digest/extconf.rb +10 -0
  16. data/ext/rubysl/digest/md5/.gitignore +2 -0
  17. data/ext/rubysl/digest/md5/extconf.rb +29 -0
  18. data/ext/rubysl/digest/md5/md5.c +422 -0
  19. data/ext/rubysl/digest/md5/md5.h +80 -0
  20. data/ext/rubysl/digest/md5/md5init.c +40 -0
  21. data/ext/rubysl/digest/md5/md5ossl.c +9 -0
  22. data/ext/rubysl/digest/md5/md5ossl.h +13 -0
  23. data/ext/rubysl/digest/rmd160/.gitignore +2 -0
  24. data/ext/rubysl/digest/rmd160/extconf.rb +28 -0
  25. data/ext/rubysl/digest/rmd160/rmd160.c +457 -0
  26. data/ext/rubysl/digest/rmd160/rmd160.h +56 -0
  27. data/ext/rubysl/digest/rmd160/rmd160init.c +40 -0
  28. data/ext/rubysl/digest/rmd160/rmd160ossl.c +8 -0
  29. data/ext/rubysl/digest/rmd160/rmd160ossl.h +19 -0
  30. data/ext/rubysl/digest/sha1/.gitignore +2 -0
  31. data/ext/rubysl/digest/sha1/extconf.rb +28 -0
  32. data/ext/rubysl/digest/sha1/sha1.c +269 -0
  33. data/ext/rubysl/digest/sha1/sha1.h +39 -0
  34. data/ext/rubysl/digest/sha1/sha1init.c +40 -0
  35. data/ext/rubysl/digest/sha1/sha1ossl.c +10 -0
  36. data/ext/rubysl/digest/sha1/sha1ossl.h +20 -0
  37. data/ext/rubysl/digest/sha2/.gitignore +2 -0
  38. data/ext/rubysl/digest/sha2/extconf.rb +24 -0
  39. data/ext/rubysl/digest/sha2/sha2.c +919 -0
  40. data/ext/rubysl/digest/sha2/sha2.h +109 -0
  41. data/ext/rubysl/digest/sha2/sha2init.c +52 -0
  42. data/lib/digest/bubblebabble.rb +1 -0
  43. data/lib/digest/hmac.rb +302 -0
  44. data/lib/digest/md5.rb +23 -0
  45. data/lib/digest/rmd160.rb +1 -0
  46. data/lib/digest/sha1.rb +23 -0
  47. data/lib/digest/sha2.rb +74 -0
  48. data/lib/digest.rb +1 -0
  49. data/lib/rubysl/digest/digest.rb +88 -0
  50. data/lib/{rubysl-digest → rubysl/digest}/version.rb +1 -1
  51. data/lib/rubysl/digest.rb +2 -0
  52. data/rubysl-digest.gemspec +25 -17
  53. data/spec/hexencode_spec.rb +30 -0
  54. data/spec/md5/append_spec.rb +6 -0
  55. data/spec/md5/block_length_spec.rb +11 -0
  56. data/spec/md5/digest_bang_spec.rb +12 -0
  57. data/spec/md5/digest_length_spec.rb +11 -0
  58. data/spec/md5/digest_spec.rb +31 -0
  59. data/spec/md5/equal_spec.rb +37 -0
  60. data/spec/md5/file_spec.rb +42 -0
  61. data/spec/md5/hexdigest_bang_spec.rb +13 -0
  62. data/spec/md5/hexdigest_spec.rb +31 -0
  63. data/spec/md5/inspect_spec.rb +11 -0
  64. data/spec/md5/length_spec.rb +7 -0
  65. data/spec/md5/reset_spec.rb +14 -0
  66. data/spec/md5/shared/constants.rb +16 -0
  67. data/spec/md5/shared/length.rb +8 -0
  68. data/spec/md5/shared/sample.rb +15 -0
  69. data/spec/md5/shared/update.rb +7 -0
  70. data/spec/md5/size_spec.rb +7 -0
  71. data/spec/md5/to_s_spec.rb +21 -0
  72. data/spec/md5/update_spec.rb +6 -0
  73. data/spec/sha1/digest_spec.rb +19 -0
  74. data/spec/sha1/file_spec.rb +42 -0
  75. data/spec/sha1/shared/constants.rb +16 -0
  76. data/spec/sha256/append_spec.rb +6 -0
  77. data/spec/sha256/block_length_spec.rb +11 -0
  78. data/spec/sha256/digest_bang_spec.rb +12 -0
  79. data/spec/sha256/digest_length_spec.rb +11 -0
  80. data/spec/sha256/digest_spec.rb +31 -0
  81. data/spec/sha256/equal_spec.rb +36 -0
  82. data/spec/sha256/file_spec.rb +42 -0
  83. data/spec/sha256/hexdigest_bang_spec.rb +13 -0
  84. data/spec/sha256/hexdigest_spec.rb +31 -0
  85. data/spec/sha256/inspect_spec.rb +11 -0
  86. data/spec/sha256/length_spec.rb +7 -0
  87. data/spec/sha256/reset_spec.rb +14 -0
  88. data/spec/sha256/shared/constants.rb +16 -0
  89. data/spec/sha256/shared/length.rb +8 -0
  90. data/spec/sha256/shared/update.rb +7 -0
  91. data/spec/sha256/size_spec.rb +7 -0
  92. data/spec/sha256/to_s_spec.rb +20 -0
  93. data/spec/sha256/update_spec.rb +6 -0
  94. data/spec/sha384/append_spec.rb +6 -0
  95. data/spec/sha384/block_length_spec.rb +11 -0
  96. data/spec/sha384/digest_bang_spec.rb +12 -0
  97. data/spec/sha384/digest_length_spec.rb +11 -0
  98. data/spec/sha384/digest_spec.rb +31 -0
  99. data/spec/sha384/equal_spec.rb +36 -0
  100. data/spec/sha384/file_spec.rb +42 -0
  101. data/spec/sha384/hexdigest_bang_spec.rb +13 -0
  102. data/spec/sha384/hexdigest_spec.rb +31 -0
  103. data/spec/sha384/inspect_spec.rb +11 -0
  104. data/spec/sha384/length_spec.rb +7 -0
  105. data/spec/sha384/reset_spec.rb +14 -0
  106. data/spec/sha384/shared/constants.rb +17 -0
  107. data/spec/sha384/shared/length.rb +8 -0
  108. data/spec/sha384/shared/update.rb +7 -0
  109. data/spec/sha384/size_spec.rb +7 -0
  110. data/spec/sha384/to_s_spec.rb +20 -0
  111. data/spec/sha384/update_spec.rb +6 -0
  112. data/spec/sha512/append_spec.rb +6 -0
  113. data/spec/sha512/block_length_spec.rb +11 -0
  114. data/spec/sha512/digest_bang_spec.rb +12 -0
  115. data/spec/sha512/digest_length_spec.rb +11 -0
  116. data/spec/sha512/digest_spec.rb +31 -0
  117. data/spec/sha512/equal_spec.rb +36 -0
  118. data/spec/sha512/file_spec.rb +42 -0
  119. data/spec/sha512/hexdigest_bang_spec.rb +13 -0
  120. data/spec/sha512/hexdigest_spec.rb +31 -0
  121. data/spec/sha512/inspect_spec.rb +11 -0
  122. data/spec/sha512/length_spec.rb +7 -0
  123. data/spec/sha512/reset_spec.rb +14 -0
  124. data/spec/sha512/shared/constants.rb +16 -0
  125. data/spec/sha512/shared/length.rb +8 -0
  126. data/spec/sha512/shared/update.rb +7 -0
  127. data/spec/sha512/size_spec.rb +7 -0
  128. data/spec/sha512/to_s_spec.rb +20 -0
  129. data/spec/sha512/update_spec.rb +6 -0
  130. metadata +283 -88
  131. 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
@@ -15,4 +15,3 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- .rbx
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
5
+ rvm:
6
+ - 1.8.7
7
+ - rbx-nightly-18mode
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RubySL::Digest
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 'Added some feature'`)
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
@@ -1,2 +1 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ Makefile
2
+ *.log
@@ -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,2 @@
1
+ #include "ruby.h"
2
+ #include "digest.h"
@@ -0,0 +1,3 @@
1
+ bubblebabble.o: bubblebabble.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
2
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
3
+ $(srcdir)/../defs.h
@@ -0,0 +1,4 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_CONFIG_H 1
4
+ #endif
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+
3
+ $defs << "-DHAVE_CONFIG_H"
4
+ $INCFLAGS << " -I$(srcdir)/.."
5
+
6
+ create_makefile('digest/bubblebabble/bubblebabble')
@@ -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 */