Ruby: file encryption/decryption with private/public keys

前端 未结 4 1009
醉话见心
醉话见心 2020-12-05 04:53

I am searching for an algorithm for file encryption/decryption which satisfies the following requirements:

  • Algorithm must be reliable
  • Algorithm should
4条回答
  •  爱一瞬间的悲伤
    2020-12-05 05:47

    I made a gem to help with this. It's called cryptosystem. Simply configure the path and password to your private key as well as the path to your public key, and it does the rest.

    Encrypting is as simple as:

    rsa = Cryptosystem::RSA.new
    rsa.encrypt('secret') # => "JxpuhTpEqRtMLmaSfaq/X6XONkBnMe..."
    

    And decrypting:

    encrypted_value = rsa.encrypt('secret') # => "Y8DWJc2/+7TIxdLEolV99XI2sclHuK..."
    rsa.decrypt(encrypted_value) # => "secret"
    

    You can check it out on GitHub or RubyGems.

提交回复
热议问题