Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../usr/share/ruby/openssl
File: cipher.rb
# frozen_string_literal: false
[0] Fix | Delete
#--
[1] Fix | Delete
# = Ruby-space predefined Cipher subclasses
[2] Fix | Delete
#
[3] Fix | Delete
# = Info
[4] Fix | Delete
# 'OpenSSL for Ruby 2' project
[5] Fix | Delete
# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
[6] Fix | Delete
# All rights reserved.
[7] Fix | Delete
#
[8] Fix | Delete
# = Licence
[9] Fix | Delete
# This program is licensed under the same licence as Ruby.
[10] Fix | Delete
# (See the file 'LICENCE'.)
[11] Fix | Delete
#++
[12] Fix | Delete
[13] Fix | Delete
module OpenSSL
[14] Fix | Delete
class Cipher
[15] Fix | Delete
%w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
[16] Fix | Delete
klass = Class.new(Cipher){
[17] Fix | Delete
define_method(:initialize){|*args|
[18] Fix | Delete
cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
[19] Fix | Delete
super(cipher_name.downcase)
[20] Fix | Delete
}
[21] Fix | Delete
}
[22] Fix | Delete
const_set(name, klass)
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
%w(128 192 256).each{|keylen|
[26] Fix | Delete
klass = Class.new(Cipher){
[27] Fix | Delete
define_method(:initialize){|mode = "CBC"|
[28] Fix | Delete
super("aes-#{keylen}-#{mode}".downcase)
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
const_set("AES#{keylen}", klass)
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
# call-seq:
[35] Fix | Delete
# cipher.random_key -> key
[36] Fix | Delete
#
[37] Fix | Delete
# Generate a random key with OpenSSL::Random.random_bytes and sets it to
[38] Fix | Delete
# the cipher, and returns it.
[39] Fix | Delete
#
[40] Fix | Delete
# You must call #encrypt or #decrypt before calling this method.
[41] Fix | Delete
def random_key
[42] Fix | Delete
str = OpenSSL::Random.random_bytes(self.key_len)
[43] Fix | Delete
self.key = str
[44] Fix | Delete
end
[45] Fix | Delete
[46] Fix | Delete
# call-seq:
[47] Fix | Delete
# cipher.random_iv -> iv
[48] Fix | Delete
#
[49] Fix | Delete
# Generate a random IV with OpenSSL::Random.random_bytes and sets it to the
[50] Fix | Delete
# cipher, and returns it.
[51] Fix | Delete
#
[52] Fix | Delete
# You must call #encrypt or #decrypt before calling this method.
[53] Fix | Delete
def random_iv
[54] Fix | Delete
str = OpenSSL::Random.random_bytes(self.iv_len)
[55] Fix | Delete
self.iv = str
[56] Fix | Delete
end
[57] Fix | Delete
[58] Fix | Delete
# Deprecated.
[59] Fix | Delete
#
[60] Fix | Delete
# This class is only provided for backwards compatibility.
[61] Fix | Delete
# Use OpenSSL::Cipher.
[62] Fix | Delete
class Cipher < Cipher; end
[63] Fix | Delete
deprecate_constant :Cipher
[64] Fix | Delete
end # Cipher
[65] Fix | Delete
end # OpenSSL
[66] Fix | Delete
[67] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function