require "openssl"
require "base64"
def des_encrypt(str)
cipher = OpenSSL::Cipher::Cipher.new("des-ecb")
cipher.encrypt
cipher.key = 'SSOFOUNDER'
# cipher.random_iv
# cipher.iv = IV
en_str = cipher.update(str)
en_str << cipher.final
return Base64.encode64(en_str)
end
def des_decrypt(enscrypt_str)
cipher = OpenSSL::Cipher::Cipher.new("des-ecb")
cipher.decrypt
cipher.key = 'SSOFOUNDER'
# cipher.random_iv
# cipher.iv = IV
cipher.update(Base64.decode64(enscrypt_str)) + cipher.final
# des_str << cipher.final
end
require "base64"
def des_encrypt(str)
cipher = OpenSSL::Cipher::Cipher.new("des-ecb")
cipher.encrypt
cipher.key = 'SSOFOUNDER'
# cipher.random_iv
# cipher.iv = IV
en_str = cipher.update(str)
en_str << cipher.final
return Base64.encode64(en_str)
end
def des_decrypt(enscrypt_str)
cipher = OpenSSL::Cipher::Cipher.new("des-ecb")
cipher.decrypt
cipher.key = 'SSOFOUNDER'
# cipher.random_iv
# cipher.iv = IV
cipher.update(Base64.decode64(enscrypt_str)) + cipher.final
# des_str << cipher.final
end