Base64Encoder cuts off last 4 characters of string

Edit Completely changed question after finding that the problem was elsewhere in the application.

I am working on a Heroku client in Flex and am trying to build the authentication tool now. Heroku uses Basic HTTP Authentication so I setup my User class to store an email and password and expose a method that will return the base64 encoded string representation of the email and password seperated by a colon. The encoder, however, cuts off the last 4 characters in the string (tested by encoding the same string through the openssl encoder built into *Nix. The code that I am using to encode the values is as follows:

public function getAuthString():String{
    var encoder:Base64Encoder = new Base64Encoder();
    encoder.insertNewLines = false;
    encoder.encode(email + ':' + password);
    trace(email + ':' + password);
    trace(encoder.toString());
    return encoder.toString();
}

The trace of the email and password together is correct, but the encoder.toString() call returns a string that is short 4 characters (45 characters long instead of 49).

Has anyone else run into this problem before? If so how did you fix it?

Answers


The ActionScript implementation is working as expected. The openssl implementation has the assumption of a newline. The extra four characters you are seeing are the newline character.


Need Your Help

how to align two labels and two textboxes without a gap in form-horizontal?

c# asp.net twitter-bootstrap webforms

I am pretty new to using Bootstrap, and have hit a brick wall when trying to have a label, a textbox, a label and a textbox on the same line without a big gap between, and so that the State TextBox...

Possible to write bigram (or ngram) function using reduce in Javascript?

javascript functional-programming reduce n-gram

I know that the .reduce function in Javascript has a notion of previous and current variables "built-in", so to speak, in its definition. So I'm curious why this doesn't work: