c_crypt 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Makefile ADDED
@@ -0,0 +1,150 @@
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
data/README.rdoc ADDED
@@ -0,0 +1,54 @@
1
+ = CCrypt
2
+
3
+ * http://github.com/brightbox/c_crypt
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ruby wrapper for the C crypt() function.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Only builds against Ubuntu
12
+ * Probably not thread safe
13
+
14
+ == SYNOPSIS:
15
+
16
+ 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.
17
+ See +man 3 crypt+ for more help.
18
+
19
+ CCrypt.crypt3 "opensourceftw", "$6$3M7.v1fn"
20
+ # >> "$6$3M7.v1fn$wnZOFg5k99FJ2p4DDVrDy9uJgv4ow.gi4B0Qz.ppWCvBI6FFtEVwtbwCIBbxo59mu5qhE0sS2Bc6zY09GZPC20"
21
+
22
+ == REQUIREMENTS:
23
+
24
+ * Ubuntu
25
+ * Ruby 1.8
26
+
27
+ == INSTALL:
28
+
29
+ * sudo gem install c_crypt
30
+
31
+ == LICENSE:
32
+
33
+ (The MIT License)
34
+
35
+ Copyright (c) 2010 Brightbox Systems Ltd. <hello@brightbox.co.uk>
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining
38
+ a copy of this software and associated documentation files (the
39
+ 'Software'), to deal in the Software without restriction, including
40
+ without limitation the rights to use, copy, modify, merge, publish,
41
+ distribute, sublicense, and/or sell copies of the Software, and to
42
+ permit persons to whom the Software is furnished to do so, subject to
43
+ the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be
46
+ included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
49
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
52
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
54
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require "rake/extensiontask"
2
+
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = "c_crypt"
5
+ s.version = "0.1"
6
+ s.author = "Caius Durling"
7
+ s.email = "caius@brightbox.co.uk"
8
+ s.homepage = "http://github.com/brightbox/c_crypt"
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = "Ruby wrapper for the C crypt() function."
11
+ s.files = FileList["ext/**/*", "lib/**/*.rb", "[A-Z]*"].to_a
12
+ s.extensions = FileList["ext/**/extconf.rb"]
13
+ s.has_rdoc = false
14
+ end
15
+
16
+ # add your default gem packing task
17
+ Rake::GemPackageTask.new(spec) do |pkg|
18
+ end
19
+
20
+ # feed your ExtensionTask with your spec
21
+ Rake::ExtensionTask.new('c_crypt', spec)
@@ -0,0 +1,34 @@
1
+ #include <ruby.h>
2
+ #include <crypt.h>
3
+
4
+ // Define our module constant
5
+ VALUE CCrypt = Qnil;
6
+
7
+ // Prototype this
8
+ void Init_c_crypt();
9
+
10
+ // Prototype CCrypt.crypt3
11
+ VALUE method_crypt3();
12
+
13
+ // Define our module & method
14
+ void Init_c_crypt() {
15
+ CCrypt = rb_define_module("CCrypt");
16
+ int arg_count = 2;
17
+ rb_define_module_function(CCrypt, "crypt3", method_crypt3, arg_count);
18
+ }
19
+
20
+ // Implement CCrypt.crypt3
21
+ VALUE method_crypt3(VALUE self, VALUE str_arg, VALUE salt_arg) {
22
+ char* str = RSTRING(str_arg)->ptr;
23
+ char* salt = RSTRING(salt_arg)->ptr;
24
+
25
+ // printf("str: %s\n", str);
26
+ // printf("salt: %s\n", salt);
27
+
28
+ char *hashed = crypt(str, salt);
29
+
30
+ // printf("hashed: %s\n", hashed);
31
+
32
+ return rb_str_new2(hashed);
33
+ }
34
+
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+
3
+ dir_config("c_crypt")
4
+
5
+ create_makefile("c_crypt")
6
+
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c_crypt
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Caius Durling
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-24 00:00:00 +00:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: caius@brightbox.co.uk
23
+ executables: []
24
+
25
+ extensions:
26
+ - ext/c_crypt/extconf.rb
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - ext/c_crypt/c_crypt.c
31
+ - ext/c_crypt/extconf.rb
32
+ - Makefile
33
+ - Rakefile
34
+ - README.rdoc
35
+ has_rdoc: true
36
+ homepage: http://github.com/brightbox/c_crypt
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Ruby wrapper for the C crypt() function.
69
+ test_files: []
70
+