20 lines
		
	
	
		
			329 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			329 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
require 'gpgme'
 | 
						|
 | 
						|
module UserManager
 | 
						|
  class PgpEncrypt < UserManagerService
 | 
						|
    def initialize(user:, text:)
 | 
						|
      @user = user
 | 
						|
      @text = text
 | 
						|
    end
 | 
						|
 | 
						|
    def call
 | 
						|
      crypto = GPGME::Crypto.new
 | 
						|
      crypto.encrypt(
 | 
						|
        @text,
 | 
						|
        recipients: @user.gnupg_key,
 | 
						|
        always_trust: true
 | 
						|
      )
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 |