0

I need to encrypt a integer, but all the crypto libraries only support strings.

What is the proper method to convert a integer to a binary string in Ruby? (not '10111', I think that it's ASCII values)

EDIT: I wasn't thinking about Rijndael as stream encryption.

1 Answer 1

1

Stream encryption algorithms work on streams -- a sequence of characters. It is upto you to treat is as an integer or a newline.

Rijndael (a block cipher) will happily accept a non-128 bit string (stream, if you will) and padd the end with 0s. Check out the documentation and give it a shot.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm using Rijndael (AES) with the Crypt gem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.