Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top