Converting Javascript Encryption Method to Java

So I found part of an encryption that I’m not advanced enough in to convert to java,

This is the javascript encryption:

function rstr2binl(input)
{
  var output = Array(input.length >> 2);
  for(var i = 0; i < output.length; i++)
    output[i] = 0;
  for(var i = 0; i < input.length * 8; i += 8)
    output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
  return output;
}

I had trouble trying to figure out kind of data the output can be.

Here was my attempt:

private static String rstr2binl(String input)
{
  int[] output = {input.length() >> 2};
  for(int i = 0; i < output.length; i++)
    output[i] = 0;
  for(int i = 0; i < input.length() * 8; i += 8)
    output[i>>5] |= (input.charAt(i / 8) & 0xFF) << (i%32);
  return output;
}

Would anybody be able to show me how to convert this javascript to java? Thank you I appreciate all answers!


Source: javascript

Leave a Reply