Sha256: 7e0cfa6f7572c022a95c90f61c54b918f7239ee84e109b2da6258074ec7cbcea

Contents?: true

Size: 666 Bytes

Versions: 7

Compression:

Stored size: 666 Bytes

Contents

module ZMQ
  
  # Secure authentication and confidentiality.
  class Curve
    
    # Generate a keypair.
    # Returns a hash with the :public and :private keys.
    def self.keypair
      public_key  = FFI::MemoryPointer.new :char, 41, true
      private_key = FFI::MemoryPointer.new :char, 41, true
      
      rc = LibZMQ::zmq_curve_keypair public_key, private_key
      
      begin
        ZMQ.error_check true if rc==-1
      rescue Errno::EOPNOTSUPP
        raise Errno::EOPNOTSUPP, "Curve requires libzmq to be compiled with libsodium."
      end
      
      { public: public_key.read_string, private: private_key.read_string }
    end
    
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
0mq-0.5.3 lib/0mq/curve.rb
0mq-0.5.2 lib/0mq/curve.rb
0mq-0.5.1 lib/0mq/curve.rb
0mq-0.5.0 lib/0mq/curve.rb
0mq-0.4.1 lib/0mq/curve.rb
0mq-0.4.0 lib/0mq/curve.rb
0mq-0.3.0 lib/0mq/curve.rb