jsencrypt
jsencrypt copied to clipboard
Support encryption and decryption without padding
I need to implement deterministic RSA encryption on serverside(Ruby) and then decrypt this data on frontend. My ruby code:
require 'openssl'
require 'base64'
KEY_SIZE=2048
message = 'Test message'
if message.length < KEY_SIZE
message = message + (' ' * (KEY_SIZE / 8 - message.length))
end
key_file = File.read('public.pem')
public_key = OpenSSL::PKey::RSA.new key_file
result = Base64.encode64(public_key.public_encrypt(message, OpenSSL::PKey::RSA::NO_PADDING))
puts result
But, jsencrypt can't decrypt it=( Is there any workarounds?
@zhulik did you ever figure out a workaround for this?
From what i've read RSA without padding makes it deterministic, but unfortunately insecure. Hashes are preferred. See this excellent SO answer: https://stackoverflow.com/a/47096284