Reputation: 2179
I have a node.js server that will encrypt a string and store it into a database. I also have a RoR(Ruby on Rails) server that will retrieve the encrypted string from the database and decrypt it. The only criteria I have is that the encryption must only encrypt strings into a string of letters and numbers (no special characters)
Any suggestions
Upvotes: 1
Views: 608
Reputation: 15693
As others have suggested, a strong encryption like AES-CBC or AES-CTR together with Base-64 is one solution. Base-64 uses +, / and = in addition to the 62 alphanumeric characters. Hex (Base-16) is strictly alphanumeric, but takes more storage space. Base-32 only has the padding character, =, like Base-64. In a pinch it is possible to omit padding, and to recalculate in for decoding.
If you are wiling to accept a lower level of security then one alternative is to use a Vigenère cypher, where you can explicitly determine the input and output characters allowed.
Upvotes: 1