File: create_encrypted_key.rb

package info (click to toggle)
rubygems 3.6.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 37,448 kB
  • sloc: ruby: 141,650; sh: 94; makefile: 28
file content (17 lines) | stat: -rw-r--r-- 410 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

require "openssl"

test_path = File.expand_path("../test/rubygems", __dir__)

private_key_path = "#{test_path}/private_key.pem"

key = OpenSSL::PKey::RSA.new File.read private_key_path

cipher = OpenSSL::Cipher.new "AES-256-CBC"

encrypted_key_path = "#{test_path}/encrypted_private_key.pem"

File.open encrypted_key_path, "w" do |io|
  io.write key.to_pem cipher, "Foo bar"
end