ruby-cakemail 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/lib/cakemail/campaign.rb +83 -0
- data/lib/cakemail/client.rb +161 -0
- data/lib/cakemail/country.rb +23 -0
- data/lib/cakemail/group.rb +102 -0
- data/lib/cakemail/list.rb +336 -0
- data/lib/cakemail/mailing.rb +215 -0
- data/lib/cakemail/relay.rb +64 -0
- data/lib/cakemail/service.rb +46 -0
- data/lib/cakemail/session.rb +70 -0
- data/lib/cakemail/suppressionlist.rb +102 -0
- data/lib/cakemail/template.rb +81 -0
- data/lib/cakemail/trigger.rb +98 -0
- data/lib/cakemail/user.rb +179 -0
- data/lib/crypto/ecb_null_padded_blowfish.rb +89 -0
- data/lib/ruby-cakemail.rb +22 -0
- metadata +98 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
# Template is HTML or Text based content that may be stored for later use.
|
2
|
+
module CakeMail
|
3
|
+
module API
|
4
|
+
class ClassTemplate < CakeMail::ServiceClass
|
5
|
+
method :name => "Create", :requires => [ :name, :user_key ], :optional => [ :type, :message ]
|
6
|
+
method :name => "Delete", :requires => [ :template_id, :user_key ]
|
7
|
+
method :name => "GetList", :requires => [ :user_key ], :optional => [ :type, :limit, :offset, :count ]
|
8
|
+
method :name => "GetInfo", :requires => [ :template_id, :user_key ]
|
9
|
+
method :name => "SetInfo", :requires => [ :template_id, :user_key ], :optional => [ :name, :message, :type ]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Template
|
14
|
+
attr_reader :id, :client_id
|
15
|
+
attr_accessor :name, :message, :type
|
16
|
+
|
17
|
+
def initialize(id, user)
|
18
|
+
@user = user
|
19
|
+
@id = id
|
20
|
+
get_info
|
21
|
+
end
|
22
|
+
# Deletes a template.
|
23
|
+
def delete
|
24
|
+
@user.session.request("CakeMail::API::ClassTemplate", "Delete", { :template_id => @id, :user_key => @user.user_key })
|
25
|
+
self.freeze
|
26
|
+
end
|
27
|
+
# Returns information about a template.
|
28
|
+
def get_info(id = @id)
|
29
|
+
res = @user.session.request("CakeMail::API::ClassTemplate", "GetInfo", { :template_id => id, :user_key => @user.user_key })
|
30
|
+
@id = res['id'].first
|
31
|
+
@client_id = res['client_id'].first
|
32
|
+
@name = res['name'].first
|
33
|
+
@type = res['type'].first
|
34
|
+
@message = res['message'].first
|
35
|
+
end
|
36
|
+
|
37
|
+
def save
|
38
|
+
self.setinfo
|
39
|
+
end
|
40
|
+
# Modifies a template.
|
41
|
+
def set_info
|
42
|
+
args = { :template_id => @id, :user_key => @user.user_key }
|
43
|
+
args[:name] = @name unless @name.nil?
|
44
|
+
args[:message] = @message unless @message.nil?
|
45
|
+
args[:type] = @type unless @type
|
46
|
+
res = @user.session.request("CakeMail::API::ClassTemplate", "SetInfo", args)
|
47
|
+
end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
# Creates a new template.
|
51
|
+
#
|
52
|
+
# Arguments :
|
53
|
+
# * options = { :user => required, :name => required, :type => optional, :message => optional }
|
54
|
+
def create(args)
|
55
|
+
raise ArgumentError if args.nil? or args[:user].nil?
|
56
|
+
options = { :name => name, :user_key => args[:user].user_key }
|
57
|
+
options[:type] = args[:type] unless args[:type].nil?
|
58
|
+
options[:message] = args[:message] unless args[:message].nil?
|
59
|
+
res = args[:user].session.request("CakeMail::API::ClassTemplate", "Create", options)
|
60
|
+
Template.new(res['id'].first, args[:user])
|
61
|
+
end
|
62
|
+
# Retrieves the list of template.
|
63
|
+
#
|
64
|
+
# Arguments :
|
65
|
+
# * args = { :user => required, :count => optional, :type => optional, :limit => optional, :offset => optional }
|
66
|
+
def get_list(args)
|
67
|
+
raise ArgumentError if args.nil? or args[:user].nil?
|
68
|
+
options = { :user_key => args[:user].user_key }
|
69
|
+
options[:type] = args[:type] unless args[:status].nil?
|
70
|
+
options[:limit] = args[:limit] unless args[:limit].nil?
|
71
|
+
options[:offset] = args[:offset] unless args[:offset].nil?
|
72
|
+
options[:count] = args[:count] unless args[:count].nil?
|
73
|
+
res = args[:user].session.request("CakeMail::API::ClassTemplate", "GetList", options)
|
74
|
+
if !args[:count].nil?
|
75
|
+
return res['count']
|
76
|
+
end
|
77
|
+
return res['template']
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# A Trigger in an individual email that is sent to a recipient following a specific action.
|
2
|
+
module CakeMail
|
3
|
+
module API
|
4
|
+
class ClassTrigger < CakeMail::ServiceClass
|
5
|
+
method :name => "Create", :requires => [ :name, :list_id, :user_key ], :optional => [ :encoding ]
|
6
|
+
method :name => "GetInfo", :requires => [ :trigger_id, :user_key ]
|
7
|
+
method :name => "GetList", :requires => [ :user_key ], :optional => [ :status, :action, :list_id, :parent_id, :limit, :offset, :count ]
|
8
|
+
method :name => "SetInfo", :requires => [ :trigger_id, :user_key ], :optional => [ :status, :encoding, :action, :name,
|
9
|
+
:delay, :parent_id, :send_to, :subject, :sender_name, :sender_email, :html_message, :text_message ]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Trigger
|
14
|
+
attr_reader :id
|
15
|
+
attr_accessor :status, :encoding, :action, :name, :delay, :parent_id, :send_to, :subject, :sender_name, :sender_email,
|
16
|
+
:html_message, :text_message
|
17
|
+
|
18
|
+
def initialize(id, user)
|
19
|
+
@user = user
|
20
|
+
@id = id
|
21
|
+
get_info
|
22
|
+
end
|
23
|
+
# Returns information about a trigger.
|
24
|
+
def get_info(id = @id)
|
25
|
+
res = @user.session.request("CakeMail::API::ClassTrigger", "GetInfo", { :trigger_id => id, :user_key => @user.user_key })
|
26
|
+
@id = res['id'].first
|
27
|
+
@status = res['status'].first
|
28
|
+
@encoding = res['encoding'].first
|
29
|
+
@action = res['action'].first
|
30
|
+
@name = res['name'].first
|
31
|
+
@description = res['description'].first
|
32
|
+
@delay = res['delay'].first
|
33
|
+
@parent_id = res['list_id'].first
|
34
|
+
@send_to = res['send_to'].first
|
35
|
+
@subject = res['subject'].first
|
36
|
+
@sender_name = res['sender_name'].first
|
37
|
+
@sender_email = res['sender_email'].first
|
38
|
+
@html_message = res['html_message'].first
|
39
|
+
@text_message = res['text_message'].first
|
40
|
+
end
|
41
|
+
|
42
|
+
def save
|
43
|
+
self.setinfo
|
44
|
+
end
|
45
|
+
# Returns information about a trigger.
|
46
|
+
def set_info
|
47
|
+
args = { :trigger_id => id, :user_key => @user.user_key }
|
48
|
+
args[:status] = status unless status.nil?
|
49
|
+
args[:encoding] = encoding unless encoding.nil?
|
50
|
+
args[:action] = action unless action.nil?
|
51
|
+
args[:name] = name unless name.nil?
|
52
|
+
args[:description] = description unless description.nil?
|
53
|
+
args[:delay] = delay unless delay.nil?
|
54
|
+
args[:parent_id] = parent_id unless parent_id.nil?
|
55
|
+
args[:send_to] = send_to unless send_to.nil?
|
56
|
+
args[:subject] = subject unless subject.nil?
|
57
|
+
args[:sender_name] = sender_name unless sender_name.nil?
|
58
|
+
args[:html_message] = html_message unless html_message.nil?
|
59
|
+
args[:text_message] = text_message unless text_message.nil?
|
60
|
+
res = @user.session.request("CakeMail::API::ClassTrigger", "SetInfo", args)
|
61
|
+
end
|
62
|
+
|
63
|
+
class << self
|
64
|
+
# Creates a trigger.
|
65
|
+
#
|
66
|
+
# Arguments :
|
67
|
+
# * args = { :user => required, :name => required, :list_id => required, :encoding => optional, :description => optional }
|
68
|
+
def create(args)
|
69
|
+
raise ArgumentError if args.nil? or args[:user].nil? or args[:name].nil? or args[:list_id]
|
70
|
+
options = { :list_id => args[:list_id], :name => args[:name], :user_key => args[:user].user_key }
|
71
|
+
options[:encoding] = args[:encoding] unless args[:encoding].nil?
|
72
|
+
options[:description] = args[:description] unless args[:description].nil?
|
73
|
+
res = args[:user].session.request("CakeMail::API::ClassTrigger", "Create", options)
|
74
|
+
Trigger.new(res['id'].first, args[:user])
|
75
|
+
end
|
76
|
+
# Retrieves the list of triggers.
|
77
|
+
#
|
78
|
+
# * args = { :user => required, :status => optional, :action => optional, :list_id => optional, :parent_id => optional,
|
79
|
+
# :limit => optional, :offset => optional, :count => optional }
|
80
|
+
def get_list(args)
|
81
|
+
raise ArgumentError if args.nil? or args[:user].nil?
|
82
|
+
options = { :user_key => args[:user].user_key }
|
83
|
+
options[:status] = args[:status] unless args[:status].nil?
|
84
|
+
options[:action] = args[:action] unless args[:action].nil?
|
85
|
+
options[:list_id] = args[:list_id] unless args[:list_id].nil?
|
86
|
+
options[:parent_id] = args[:parent_id] unless args[:parent_id].nil?
|
87
|
+
options[:limit] = args[:limit] unless args[:limit].nil?
|
88
|
+
options[:offset] = args[:offset] unless args[:offset].nil?
|
89
|
+
options[:count] = args[:count] unless args[:count].nil?
|
90
|
+
res = args[:user].session.request("CakeMail::API::ClassTrigger", "GetList", options)
|
91
|
+
if !args[:count].nil?
|
92
|
+
return res['count'].first
|
93
|
+
end
|
94
|
+
return res['trigger']
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# A User is an individual associated to a Client. A User has access to a single Account.
|
2
|
+
#
|
3
|
+
# Most API calls require the User Key. This key (not to be confused with the Interface Key) can be obtained using the method "Login" by
|
4
|
+
# supplying the user's email and password.
|
5
|
+
module CakeMail
|
6
|
+
module API
|
7
|
+
class ClassUser < CakeMail::ServiceClass
|
8
|
+
method :name => "Create", :requires => [ :email, :first_name, :last_name, :password, :password_confirmation, :user_key ],
|
9
|
+
:optional => [ :language, :mobile_phone, :office_phone, :timezone_id, :title ]
|
10
|
+
method :name => "GetInfo", :requires => [ :user_key ], :optional => [ :user_id ]
|
11
|
+
method :name => "GetList", :requires => [ :status, :user_key ], :optional => [ :count, :limit, :offset ]
|
12
|
+
method :name => "Login", :requires => [ :email, :password ]
|
13
|
+
method :name => "PasswordRecovery", :requires => [ :email, :subject, :text ], :optional => [ :encoding, :headers, :html ]
|
14
|
+
method :name => "SetInfo", :requires => [ :user_id, :user_key ], :optional => [ :email, :password, :password_confirmation,
|
15
|
+
:status, :first_name, :last_name, :title, :language, :timezone_id, :office_phone, :mobile_phone, :wysiwyg ]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class User
|
20
|
+
attr_reader :user_id, :client_id, :created_on, :timezone, :timezone_id, :last_activity, :groups, :session
|
21
|
+
attr_accessor :email, :first_name, :language, :last_name, :mobile_phone, :office_phone, :password, :status, :title, :user_key, :wysiwyg
|
22
|
+
|
23
|
+
def initialize(session, args)
|
24
|
+
raise ArgumentError if session.nil? or args[:id].nil?
|
25
|
+
@session = session
|
26
|
+
@client_id = args[:client_id].to_i
|
27
|
+
@client_key = args[:client_key]
|
28
|
+
@id = args[:id].to_i
|
29
|
+
@user_key = args[:user_key]
|
30
|
+
get_info
|
31
|
+
end
|
32
|
+
# Creates a user.
|
33
|
+
def create(email, password, first_name, last_name, title = nil, language = 'en_US', timezone_id = 152, office_phone = nil,
|
34
|
+
mobile_phone = nil)
|
35
|
+
args = { :email => email, :password => password, :password_confirmation => password, :first_name => first_name,
|
36
|
+
:language => language, :last_name => last_name,
|
37
|
+
:timezone_id => timeezone_id, :user_key => @user_key }
|
38
|
+
args[:title] = title unless title.nil?
|
39
|
+
args[:office_phone] = office_phone unless office_phone.nil?
|
40
|
+
args[:mobile_phone] = mobile_phone unless mobile_phone.nil?
|
41
|
+
res = @session.request("CakeMail::API::ClassUser", "Create", args)
|
42
|
+
user = getinfo(res['user_id'].first.to_i)
|
43
|
+
user.user_key = res['user_key'].first
|
44
|
+
return user
|
45
|
+
end
|
46
|
+
# Retrieves informations about a user.
|
47
|
+
def get_info(id = @id)
|
48
|
+
res = @session.request("CakeMail::API::ClassUser", "GetInfo", { :user_id => id, :user_key => @user_key })
|
49
|
+
email = res['email'].first
|
50
|
+
password = res['password'].first
|
51
|
+
status = res['status'].first
|
52
|
+
created_on = res['created_on'].first
|
53
|
+
last_activity = res['last_activity'].first
|
54
|
+
first_name = res['first_name'].first
|
55
|
+
last_name = res['last_name'].first
|
56
|
+
title = res['title'].first
|
57
|
+
language = res['language'].first,
|
58
|
+
timezone = res['timezone'].first
|
59
|
+
timezone_id = res['timezone_id'].first,
|
60
|
+
office_phone = res['office_phone'].first
|
61
|
+
mobile_phone = res['mobile_phone'].first
|
62
|
+
wysiwyg = res['wysiwyg'].first
|
63
|
+
group_ids = res['group_id']
|
64
|
+
end
|
65
|
+
# Returns campaign object.
|
66
|
+
def campaign(id)
|
67
|
+
return CakeMail::Campaign.new(id, self)
|
68
|
+
end
|
69
|
+
# Creates new campaign.
|
70
|
+
def campaign_new(name)
|
71
|
+
return CakeMail::Campaign.create(name, self)
|
72
|
+
end
|
73
|
+
# Returns client object.
|
74
|
+
def client(id)
|
75
|
+
return CakeMail::Client.new(id, self)
|
76
|
+
end
|
77
|
+
# Creates a new client.
|
78
|
+
#
|
79
|
+
# Arguments :
|
80
|
+
# * args = { :company_name => required, :admin_email => required, :admin_first_name => required,
|
81
|
+
# :admin_last_name => required, :admin_password => required, :contact_email => required, :contact_first_name => required,
|
82
|
+
# :contact_last_name => required, :contact_password => required, :parent_id => optional, :currency => optional, :address1 => optional,
|
83
|
+
# :address2 => optionall, :city => optional, :province_id => optional, :country_id => optional, :postal_code => optional,
|
84
|
+
# :website => optional, :phone => optional, :fax => optional, :admin_title => optional, :admin_office_phone => required,
|
85
|
+
# :admin_mobile_phone => optional, :admin_language => optional, :contact_title => optional, :contact_language => optional,
|
86
|
+
# :contact_timezone_id => optional, :contact_office_phone => optional, :contact_mobile_phone => optional }
|
87
|
+
def client_new(args)
|
88
|
+
raise ArgumentError if args.nil? or args[:user].nil? or args[:company_name].nil? or args[:admin_email].nil? or
|
89
|
+
args[:admin_first_name].nil? or args[:admin_last_name].nil? or args[:admin_password].nil? or args[:contact_email].nil? or
|
90
|
+
args[:contact_first_name].nil? or args[:contact_last_name].nil? or args[:contact_password].nil?
|
91
|
+
args[:user] = self
|
92
|
+
return CakeMail::Client.create(args)
|
93
|
+
end
|
94
|
+
# Returns a list.
|
95
|
+
def list(id)
|
96
|
+
return CakeMail::List.new(id, self)
|
97
|
+
end
|
98
|
+
# Creates a list.
|
99
|
+
#
|
100
|
+
# Arguments :
|
101
|
+
# * args = { :name => required, :sender_name => required, :sender_email, :data => optional/custom }
|
102
|
+
# Custom argument:
|
103
|
+
# * :data => [ { :type => "text", :value => "city" }, { :type => "integer", :value => "age" }, ... ]
|
104
|
+
def list_new(args)
|
105
|
+
raise ArgumentError if args.nil? or args[:name].nil? or args[:sender_email].nil? or args[:sender_name].nil?
|
106
|
+
args[:user] = self
|
107
|
+
return CakeMail::List.create(args)
|
108
|
+
end
|
109
|
+
# Returns a group.
|
110
|
+
def group(id)
|
111
|
+
return CakeMail::Group.new(id, self)
|
112
|
+
end
|
113
|
+
# Creates a new group.
|
114
|
+
def group_new(name, client_id = nil)
|
115
|
+
args = { :user => self, :name => name }
|
116
|
+
args[:client_id] = client_id unless client_id.nil?
|
117
|
+
return CakeMail::Group.create(args)
|
118
|
+
end
|
119
|
+
# Returns a template.
|
120
|
+
def template(id)
|
121
|
+
return CakeMail::Template.new(id, self)
|
122
|
+
end
|
123
|
+
# Creates a new template.
|
124
|
+
#
|
125
|
+
# Arguments :
|
126
|
+
# * options = { :name => required, :type => optional, :message => optional }
|
127
|
+
def template_new(args)
|
128
|
+
args[:user] = self
|
129
|
+
return CakeMail::Template.create(args)
|
130
|
+
end
|
131
|
+
# Returns a trigger.
|
132
|
+
def trigger(id)
|
133
|
+
return CakeMail::Trigger.new(id, self)
|
134
|
+
end
|
135
|
+
# Creates a new trigger
|
136
|
+
#
|
137
|
+
# Arguments :
|
138
|
+
# * args = { :name => required, :list_id => required, :encoding => optional, :description => optional }
|
139
|
+
def trigger_new(args)
|
140
|
+
raise ArgumentError if args.nil? or args[:name].nil? or args[:list_id]
|
141
|
+
args[:user] = self
|
142
|
+
return CakeMail::Trigger.create(args)
|
143
|
+
end
|
144
|
+
|
145
|
+
def save
|
146
|
+
self.setinfo
|
147
|
+
end
|
148
|
+
# Modifies a user.
|
149
|
+
def set_info
|
150
|
+
args = { :user_id => @id, :user_key => @user_key }
|
151
|
+
args[:email] = @email unless @email.nil?
|
152
|
+
args[:password] = @password unless @password.nil?
|
153
|
+
args[:password_confirmation] = @password unless @password.nil?
|
154
|
+
args[:status] = @status unless @status.nil?
|
155
|
+
args[:first_name] = @first_name unless @first_name.nil?
|
156
|
+
args[:last_name] = @last_name unless @last_name.nil?
|
157
|
+
args[:title] = @title unless @title.nil?
|
158
|
+
args[:language] = @language unless @language.nil?
|
159
|
+
args[:timezone_id] = @timezone_id unless @timezone_id.nil?
|
160
|
+
args[:office_phone] = @office_phone unless @office_phone.nil?
|
161
|
+
args[:mobile_phone] = @mobile_phone unless @mobile_phone.nil?
|
162
|
+
args[:wysiwyg] = @wysiwyg unless @wysiwyg.nil?
|
163
|
+
@session.request("CakeMail::API::ClassUser", "SetInfo", args )
|
164
|
+
end
|
165
|
+
|
166
|
+
class << self
|
167
|
+
# Returns a logged in user object.
|
168
|
+
def login(session, email, password)
|
169
|
+
res = session.request("CakeMail::API::ClassUser", "Login", { :email => email, :password => password })
|
170
|
+
User.new(session, { :client_id => res['client_id'].first, :client_key => res['client_key'].first,
|
171
|
+
:id => res['user_id'].first, :user_key => res['user_key'].first })
|
172
|
+
end
|
173
|
+
# Sends by email the user's password.
|
174
|
+
def password_recovery(email, subject = "CakeMail Password Recovery", text = "Your password is: ")
|
175
|
+
session.request("CakeMail::API::ClassUser", "PasswordRecovery", { :email => email, :subject => subject, :text => text })
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Crypt
|
2
|
+
module ECB
|
3
|
+
def padded_last_block(last_block)
|
4
|
+
block = last_block || ''
|
5
|
+
buffer = block.split('')
|
6
|
+
remainingMessageBytes = buffer.length
|
7
|
+
remainingMessageBytes.upto(block_size()-1) { buffer << 0.chr }
|
8
|
+
return buffer.join('')
|
9
|
+
end
|
10
|
+
|
11
|
+
def unpadded_last_block(last_block)
|
12
|
+
block = last_block || ''
|
13
|
+
chars = block.split('')
|
14
|
+
buffer = []
|
15
|
+
chars.each do |c|
|
16
|
+
if c != 0
|
17
|
+
buffer << c
|
18
|
+
else
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return buffer.join('')
|
23
|
+
end
|
24
|
+
|
25
|
+
def encrypt_stream(plainStream, cryptStream)
|
26
|
+
while ((block = plainStream.read(block_size())) && (block.length == block_size()))
|
27
|
+
cryptStream.write(encrypt_block(block))
|
28
|
+
end
|
29
|
+
cryptStream.write(encrypt_block(padded_last_block(block)))
|
30
|
+
end
|
31
|
+
|
32
|
+
def decrypt_stream(cryptStream, plainStream)
|
33
|
+
while (block = cryptStream.read(block_size()))
|
34
|
+
plainText = decrypt_block(block)
|
35
|
+
plainStream.write(plainText) unless cryptStream.eof?
|
36
|
+
end
|
37
|
+
plainStream.write(unpadded_last_block(plainText))
|
38
|
+
end
|
39
|
+
|
40
|
+
def carefully_open_file(filename, mode)
|
41
|
+
begin
|
42
|
+
aFile = File.new(filename, mode)
|
43
|
+
rescue
|
44
|
+
puts "Sorry. There was a problem opening the file <#{filename}>."
|
45
|
+
aFile.close() unless aFile.nil?
|
46
|
+
raise
|
47
|
+
end
|
48
|
+
return(aFile)
|
49
|
+
end
|
50
|
+
|
51
|
+
def encrypt_file(plainFilename, cryptFilename)
|
52
|
+
plainFile = carefully_open_file(plainFilename, 'rb')
|
53
|
+
cryptFile = carefully_open_file(cryptFilename, 'wb+')
|
54
|
+
encrypt_stream(plainFile, cryptFile)
|
55
|
+
plainFile.close unless plainFile.closed?
|
56
|
+
cryptFile.close unless cryptFile.closed?
|
57
|
+
end
|
58
|
+
|
59
|
+
def decrypt_file(cryptFilename, plainFilename)
|
60
|
+
cryptFile = carefully_open_file(cryptFilename, 'rb')
|
61
|
+
plainFile = carefully_open_file(plainFilename, 'wb+')
|
62
|
+
decrypt_stream(cryptFile, plainFile)
|
63
|
+
cryptFile.close unless cryptFile.closed?
|
64
|
+
plainFile.close unless plainFile.closed?
|
65
|
+
end
|
66
|
+
|
67
|
+
def encrypt_string(plainText)
|
68
|
+
plainStream = StringIO.new(plainText)
|
69
|
+
cryptStream = StringIO.new('')
|
70
|
+
encrypt_stream(plainStream, cryptStream)
|
71
|
+
cryptText = cryptStream.string
|
72
|
+
return(cryptText)
|
73
|
+
end
|
74
|
+
|
75
|
+
def decrypt_string(cryptText)
|
76
|
+
cryptStream = StringIO.new(cryptText)
|
77
|
+
plainStream = StringIO.new('')
|
78
|
+
decrypt_stream(cryptStream, plainStream)
|
79
|
+
plainText = plainStream.string
|
80
|
+
return(plainText)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
module Crypt
|
86
|
+
class Blowfish
|
87
|
+
include Crypt::ECB
|
88
|
+
end
|
89
|
+
end
|