项目作者: parayaluyanta

项目描述 :
encryption-decryption pair scala
高级语言: Scala
项目地址: git://github.com/parayaluyanta/enc-dec-scala.git
创建时间: 2017-10-04T06:53:50Z
项目社区:https://github.com/parayaluyanta/enc-dec-scala

开源协议:

下载


client enc - server dec

This project shows how to encrypt a data in client using public key;
and send it over to server and decrypt it using “private key” in scala.

example:
send a encrypted data to server to get decrypted.

  1. curl -XPOST 10.0.0.179:9999 -d "5aae8b0e3db810c13876838452b18cbede9890c665f2fd2ffe2dcccd7ba414687c1a9b531ca359e26c6f4433c54644c7bdbff159e55a5544905fed7598397476fdc4164c424c1505fd7cf5b2d0fc22b6981b2e12b4daf2c55180e4324c3917a1bbbe2d03ac55b801d5f6dcdc4e57ed9404b85082574530dbb80288de837757d0f51d49d74bd31297c75d18f03c43a403f7ffd21e69c556afa6747b02df8bbff6389b5e31ff5eff3eb2d402f8b97eb310391c73212ddb51fa6b1b130a51583d8a33151cf66fd3abc18ed22f5e78b2962cb99b881ee5f63e09096c10d96f95a830cf7f8e96b2efb54f7d7b7955786b3edb0f0678c09a86b67b1ded612ad4ad5be3" -H "Accept: application/json"
  2. {
  3. "decrypted": "data to encrypt",
  4. "encrypted": "5aae8b0e3db810c13876838452b18cbede9890c665f2fd2ffe2dcccd7ba414687c1a9b531ca359e26c6f4433c54644c7bdbff159e55a5544905fed7598397476fdc4164c424c1505fd7cf5b2d0fc22b6981b2e12b4daf2c55180e4324c3917a1bbbe2d03ac55b801d5f6dcdc4e57ed9404b85082574530dbb80288de837757d0f51d49d74bd31297c75d18f03c43a403f7ffd21e69c556afa6747b02df8bbff6389b5e31ff5eff3eb2d402f8b97eb310391c73212ddb51fa6b1b130a51583d8a33151cf66fd3abc18ed22f5e78b2962cb99b881ee5f63e09096c10d96f95a830cf7f8e96b2efb54f7d7b7955786b3edb0f0678c09a86b67b1ded612ad4ad5be3"
  5. }

transformation format

RSA/ECB/OAEPWithSHA1AndMGF1Padding

decrypt a string with public key to compare with a hash

encode a string with rsa/ecb/pkcs1 padding mode with a given public key

http://www.mysamplecode.com/2011/08/rsa-encryption-decryption-using-bouncy.html

http://www.mysamplecode.com/2011/08/java-rsa-encrypt-string-using-bouncy.html

https://en.wikipedia.org/wiki/Padding_(cryptography)

  1. Official messages often start and end in predictable ways:
  2. My dear ambassador,
  3. Weather report,
  4. Sincerely yours, etc.
  5. The primary use of padding with classical ciphers is to prevent the cryptanalyst
  6. from using that predictability to find known plaintext that aids in breaking the encryption.
  7. Random length padding also prevents an attacker from knowing the exact length of the plaintext message.

https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding

  1. a padding scheme often used together with RSA encryption.

Also see: