Peter Szinek
Peter Szinek

Reputation: 71

Rijndael encryption in Ruby

I am totally new to encryption, so this question might be trivial - however, I had to google for 2 hours to understand even the basic terms, so bear with me.

The string I need to send is a Base64 Encoded String of an encrypted JSON object. Here's the spec they sent me:

I checked out crypt's Rijndael algorithm, but I don't see where to plug the IV into... Not sure if CBC and PKCS7 are default - if they aren't, I don't know how to change these either...

So:

Upvotes: 1

Views: 2507

Answers (2)

abc123
abc123

Reputation: 18783

Crypt::Rijndael

This is included in ruby now and can do the decryption of Rijndael easily.

Upvotes: 0

Bruno Rohée
Bruno Rohée

Reputation: 3534

I pretty much doubt they really use Rijndael. They likely use AES (which is is subset of Rijndael with fixed 128 bits block size and only three standardized key size (128,192 and 256 bits)). Without them supplying blocksize and keysize you cannot be sure anyway, you can likely assume AES-128, but their spec is incomplete at best.

The IV is not related to the cipher algorithm but to the chaining mode, in your case CBC.

AES, CBC, PKCS7 are available in Ruby via OpenSSL, shouldn't be too much trouble.

Edit: people thinking they use Rijndael make me think they use .NET, in which case that question should solve your issues : How to decode Rijndael in ruby (encoded in VB.net)

Upvotes: 3

Related Questions