ruby/example_code/s3/s3_add_cspk_encrypt_item.rb
def public_private_rsa_key_pair_files_created?(
  public_key_string,
  public_key_file_name,
  private_key_string,
  private_key_file_name
)
  public_key_file = File.new(public_key_file_name, 'w')
  public_key_file.write(public_key_string)
  public_key_file.close
  private_key_file = File.new(private_key_file_name, 'w')
  private_key_file.write(private_key_string)
  private_key_file.close
  return true
rescue StandardError => e
  puts "Could not create public/private key pair files: #{e.message}"
  return false
end
# Saves a set of corresponding public/private key-pair strings to
#   files on disk. Call this function if you have a set of corresponding
#   key-pair strings in memory but you have not yet saved them to disk.
#
# @param public_key_string [String] The public key string to save.
# @param public_key_file_name [String] The name of the file to save the
#    public key to.
# @param private_key_string [String] The private key string to save.
# @param private_key_file_name [String] The name of the file to save the
#    private key to.
# @return [Boolean] true if the files were saved; otherwise, false.
# @example
#     exit 1 unless public_private_rsa_key_pair_files_created?(
#       '***my public key string***',
#       'my-public-key.pem',
#       '***my private key string***',
#       'my-private-key.pem'
#     )

Saves a set of corresponding public/private key-pair strings to
files on disk. Call this function if you have a set of corresponding
key-pair strings in memory but you have not yet saved them to disk.
Saves a set of corresponding public / private key - pair strings to files on disk . Call this function if you have a set of corresponding key - pair strings in memory but you have not yet saved them to disk .
def public_private_rsa_key_pair_files_created?(
  public_key_string,
  public_key_file_name,
  private_key_string,
  private_key_file_name
)
  public_key_file = File.new(public_key_file_name, 'w')
  public_key_file.write(public_key_string)
  public_key_file.close
  private_key_file = File.new(private_key_file_name, 'w')
  private_key_file.write(private_key_string)
  private_key_file.close
  return true
rescue StandardError => e
  puts "Could not create public/private key pair files: #{e.message}"
  return false
end
def public_private_rsa_key_pair_files_created? ( public_key_string , public_key_file_name , private_key_string , private_key_file_name ) public_key_file = File . new ( public_key_file_name , 'w' ) public_key_file . write ( public_key_string ) public_key_file . close private_key_file = File . new ( private_key_file_name , 'w' ) private_key_file . write ( private_key_string ) private_key_file . close return true rescue StandardError => e puts "Could not create public/private key pair files: #{e.message}" return false end
Saves a set of corresponding public/private key-pair strings to
files on disk.
Saves a set of corresponding public / private key - pair strings to files on disk .
true if the files were saved; otherwise, false.
true if the files were saved ; otherwise false .
Boolean
public_key_string
The public key string to save.
The public key string to save .
public_key_file_name
The name of the file to save the public key to.
The name of the file to save the public key to .
private_key_string
The private key string to save.
The private key string to save .
private_key_file_name
The name of the file to save the private key to.
The name of the file to save the private key to .
example
exit 1 unless public_private_rsa_key_pair_files_created?( '***my public key string***', 'my-public-key.pem', '***my private key string***', 'my-private-key.pem' )
exit 1 unless public_private_rsa_key_pair_files_created? ( ' *** my public key string *** ' ' my - public - key . pem ' ' *** my private key string *** ' ' my - private - key . pem ' )