c_crypt 0.1 → 0.2.1

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.
Files changed (5) hide show
  1. data/README.rdoc +6 -0
  2. data/Rakefile +2 -1
  3. data/ext/c_crypt/c_crypt.c +8 -7
  4. metadata +19 -6
  5. data/Makefile +0 -150
@@ -11,6 +11,12 @@ Ruby wrapper for the C crypt() function.
11
11
  * Only builds against Ubuntu
12
12
  * Probably not thread safe
13
13
 
14
+ === OS X
15
+
16
+ Whilst the gem compiles and works on OS X, it's using the BSD crypt() function, not the GNU stdlib's function. This means you get a completely different hash back from it.
17
+
18
+ The reason "support" for OS X has been added is so our developers who use Macs can still run the applications that lean on c_crypt locally.
19
+
14
20
  == SYNOPSIS:
15
21
 
16
22
  Use it exactly the same as +crypt()+, give it a string to hash, and a salt. The start of the salt determines what algorithm is used.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require "rake/extensiontask"
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = "c_crypt"
5
- s.version = "0.1"
5
+ s.version = "0.2.1"
6
6
  s.author = "Caius Durling"
7
7
  s.email = "caius@brightbox.co.uk"
8
8
  s.homepage = "http://github.com/brightbox/c_crypt"
@@ -10,6 +10,7 @@ spec = Gem::Specification.new do |s|
10
10
  s.summary = "Ruby wrapper for the C crypt() function."
11
11
  s.files = FileList["ext/**/*", "lib/**/*.rb", "[A-Z]*"].to_a
12
12
  s.extensions = FileList["ext/**/extconf.rb"]
13
+ s.add_development_dependency "rake-compiler"
13
14
  s.has_rdoc = false
14
15
  end
15
16
 
@@ -1,5 +1,9 @@
1
1
  #include <ruby.h>
2
+ #ifdef __APPLE__
3
+ #include <unistd.h>
4
+ #else
2
5
  #include <crypt.h>
6
+ #endif
3
7
 
4
8
  // Define our module constant
5
9
  VALUE CCrypt = Qnil;
@@ -10,7 +14,7 @@ void Init_c_crypt();
10
14
  // Prototype CCrypt.crypt3
11
15
  VALUE method_crypt3();
12
16
 
13
- // Define our module & method
17
+ // Define CCrypt and the fact it has a class method called crypt3
14
18
  void Init_c_crypt() {
15
19
  CCrypt = rb_define_module("CCrypt");
16
20
  int arg_count = 2;
@@ -19,16 +23,13 @@ void Init_c_crypt() {
19
23
 
20
24
  // Implement CCrypt.crypt3
21
25
  VALUE method_crypt3(VALUE self, VALUE str_arg, VALUE salt_arg) {
26
+ // Convert args from ruby strings into char arrays
22
27
  char* str = RSTRING(str_arg)->ptr;
23
28
  char* salt = RSTRING(salt_arg)->ptr;
24
29
 
25
- // printf("str: %s\n", str);
26
- // printf("salt: %s\n", salt);
27
-
30
+ // Get back the hashed array string
28
31
  char *hashed = crypt(str, salt);
29
32
 
30
- // printf("hashed: %s\n", hashed);
31
-
33
+ // Cast it into a ruby string and return it
32
34
  return rb_str_new2(hashed);
33
35
  }
34
-
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c_crypt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 2
8
9
  - 1
9
- version: "0.1"
10
+ version: 0.2.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Caius Durling
@@ -14,10 +15,23 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-24 00:00:00 +00:00
18
+ date: 2010-08-24 00:00:00 +01:00
18
19
  default_executable:
19
- dependencies: []
20
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake-compiler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
21
35
  description:
22
36
  email: caius@brightbox.co.uk
23
37
  executables: []
@@ -29,7 +43,6 @@ extra_rdoc_files: []
29
43
  files:
30
44
  - ext/c_crypt/c_crypt.c
31
45
  - ext/c_crypt/extconf.rb
32
- - Makefile
33
46
  - Rakefile
34
47
  - README.rdoc
35
48
  has_rdoc: true
data/Makefile DELETED
@@ -1,150 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = ext/c_crypt
7
- topdir = /usr/lib/ruby/1.8/i486-linux
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- prefix = $(DESTDIR)/usr
11
- exec_prefix = $(prefix)
12
- sitedir = $(DESTDIR)/usr/local/lib/site_ruby
13
- rubylibdir = $(libdir)/ruby/$(ruby_version)
14
- docdir = $(datarootdir)/doc/$(PACKAGE)
15
- dvidir = $(docdir)
16
- datarootdir = $(prefix)/share
17
- archdir = $(rubylibdir)/$(arch)
18
- sbindir = $(exec_prefix)/sbin
19
- psdir = $(docdir)
20
- localedir = $(datarootdir)/locale
21
- htmldir = $(docdir)
22
- datadir = $(datarootdir)
23
- includedir = $(prefix)/include
24
- infodir = $(prefix)/share/info
25
- sysconfdir = $(DESTDIR)/etc
26
- mandir = $(prefix)/share/man
27
- libdir = $(exec_prefix)/lib
28
- sharedstatedir = $(prefix)/com
29
- oldincludedir = $(DESTDIR)/usr/include
30
- pdfdir = $(docdir)
31
- sitearchdir = $(sitelibdir)/$(sitearch)
32
- bindir = $(exec_prefix)/bin
33
- localstatedir = $(DESTDIR)/var
34
- sitelibdir = $(sitedir)/$(ruby_version)
35
- libexecdir = $(prefix)/lib/ruby1.8
36
-
37
- CC = cc
38
- LIBRUBY = $(LIBRUBY_SO)
39
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
41
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
42
-
43
- RUBY_EXTCONF_H =
44
- CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC
45
- INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
46
- DEFS = -D_FILE_OFFSET_BITS=64
47
- CPPFLAGS = $(DEFS)
48
- CXXFLAGS = $(CFLAGS)
49
- DLDFLAGS = -L. -Wl,-Bsymbolic-functions -ltcmalloc_minimal -rdynamic -Wl,-export-dynamic
50
- LDSHARED = $(CC) -shared
51
- AR = ar
52
- EXEEXT =
53
-
54
- RUBY_INSTALL_NAME = ruby1.8
55
- RUBY_SO_NAME = ruby1.8
56
- arch = i486-linux
57
- sitearch = i486-linux
58
- ruby_version = 1.8
59
- ruby = /usr/bin/ruby1.8
60
- RUBY = $(ruby)
61
- RM = rm -f
62
- MAKEDIRS = mkdir -p
63
- INSTALL = /usr/bin/install -c
64
- INSTALL_PROG = $(INSTALL) -m 0755
65
- INSTALL_DATA = $(INSTALL) -m 644
66
- COPY = cp
67
-
68
- #### End of system configuration section. ####
69
-
70
- preload =
71
-
72
- libpath = . $(libdir)
73
- LIBPATH = -L. -L$(libdir)
74
- DEFFILE =
75
-
76
- CLEANFILES = mkmf.log
77
- DISTCLEANFILES =
78
-
79
- extout =
80
- extout_prefix =
81
- target_prefix =
82
- LOCAL_LIBS =
83
- LIBS = $(LIBRUBYARG_SHARED) -ldl -lcrypt -lm -lc
84
- SRCS = c_crypt.c
85
- OBJS = c_crypt.o
86
- TARGET = c_crypt
87
- DLLIB = $(TARGET).so
88
- EXTSTATIC =
89
- STATIC_LIB =
90
-
91
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
92
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
93
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
94
-
95
- TARGET_SO = $(DLLIB)
96
- CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
97
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
98
-
99
- all: $(DLLIB)
100
- static: $(STATIC_LIB)
101
-
102
- clean:
103
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
104
-
105
- distclean: clean
106
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
107
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
108
-
109
- realclean: distclean
110
- install: install-so install-rb
111
-
112
- install-so: $(RUBYARCHDIR)
113
- install-so: $(RUBYARCHDIR)/$(DLLIB)
114
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
115
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
116
- install-rb: pre-install-rb install-rb-default
117
- install-rb-default: pre-install-rb-default
118
- pre-install-rb: Makefile
119
- pre-install-rb-default: Makefile
120
- $(RUBYARCHDIR):
121
- $(MAKEDIRS) $@
122
-
123
- site-install: site-install-so site-install-rb
124
- site-install-so: install-so
125
- site-install-rb: install-rb
126
-
127
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
128
-
129
- .cc.o:
130
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
131
-
132
- .cxx.o:
133
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
134
-
135
- .cpp.o:
136
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
137
-
138
- .C.o:
139
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
140
-
141
- .c.o:
142
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
143
-
144
- $(DLLIB): $(OBJS)
145
- @-$(RM) $@
146
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
147
-
148
-
149
-
150
- $(OBJS): ruby.h defines.h