-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
8
-
generic
-
windows
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows server 2012 r2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Latest java version
A DESCRIPTION OF THE PROBLEM :
We have been using salts to hash our user passwords in our database. These salts are utf-8 strings we are storing them in base64 encoded format. When decoding these base64 strings and applying the UTF-8 encoding is resulting in two different strings with java7 and java 8. We have attached the code we are using on java7 and java8. This has been major block for us to upgrade to java8.
Few Such Strings in Base64 format resulting different outputs in java 7 and java 8
1. ohAmCN+16W4=
2. CYXK/msFybjTzRxzIXKdVZQExjEN1PmSaQthELMpXp2LNJ9AkoYRQkaBx5Qt2V4CNGxITYL13vYp2wwsJ6GgmzOg0embfVJctAjMjvucYjZG+nNeZxzkZLO5ua6aqI9mt88ID07t4nwrwugVur0a8K7BfSHIDqzVQ2sdddNozbJjtg9SG/HLhYb03wFbWmsjMSdR7H8FtCXeCteNLHVyaqagAD+U9dSZzoPOJCzyE4NMjcc/Y3Gg77WpTduQOTVg6v5trLBpmmW8KPxgR8iPtEZHXZoudDs0cZUZitKtsVUx+Bg8FKmquJve2Wa0ZE3nvmZPHY59mU5aJ5o8WZ7CihUFnIxQJ7NZNf48ljHWQHysBZd5UzU8aq5FGY6cd7XYhz7odTKszzCBfyHHjijTU+hNtAinEAy4Wzis6znRkuNsM0Z+vwj8mULmbJLupo7XVtAETNhW4rR23zzd1DVT4bN1FWxTmBZnemqEAFX5D9Wli1gG/iNWQ8dDaGLn6GA7wgNsJXcY18a5Y9YOxbE01O/aLbehd4CbLA/u8UBRBUdvuq+/vEqeMlh8ShfjVtNPY6lpv5GLLM4bot4aL4rBvgq4WzboJZD7wJEJLVJVnsvGj0VUBKzMQjPI1vQjxdE5ZrOoyRIwCixt5TzQyXQ0NS05N7exKoF17HN+/d02pYg=
REGRESSION. Last worked in version 7u80
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Java 7 Code:
import sun.misc.BASE64Decoder; // once this gets fixed we are hoping to use java 8's Base64
/* Name of the class has to be "Main" only if the class is public. */
public class Main {
public static void main(String[] args) throws java.lang.Exception {
// your code goes here
String encodedString = "ohAmCN+16W4=";
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes;
decodedBytes = decoder.decodeBuffer(encodedString);
System.out.println(new String(decodedBytes, "UTF-8"));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
for base64 string ohAmCN+16W4=
?&??
ACTUAL -
for base64 string ohAmCN+16W4=
?&??n
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import sun.misc.BASE64Decoder; // once this gets fixed we are hoping to use java 8's Base64
/* Name of the class has to be "Main" only if the class is public. */
public class Main {
public static void main(String[] args) throws java.lang.Exception {
// your code goes here
String encodedString = "ohAmCN+16W4=";
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes;
decodedBytes = decoder.decodeBuffer(encodedString);
System.out.println(new String(decodedBytes, "UTF-8"));
}
}
---------- END SOURCE ----------
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows server 2012 r2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Latest java version
A DESCRIPTION OF THE PROBLEM :
We have been using salts to hash our user passwords in our database. These salts are utf-8 strings we are storing them in base64 encoded format. When decoding these base64 strings and applying the UTF-8 encoding is resulting in two different strings with java7 and java 8. We have attached the code we are using on java7 and java8. This has been major block for us to upgrade to java8.
Few Such Strings in Base64 format resulting different outputs in java 7 and java 8
1. ohAmCN+16W4=
2. CYXK/msFybjTzRxzIXKdVZQExjEN1PmSaQthELMpXp2LNJ9AkoYRQkaBx5Qt2V4CNGxITYL13vYp2wwsJ6GgmzOg0embfVJctAjMjvucYjZG+nNeZxzkZLO5ua6aqI9mt88ID07t4nwrwugVur0a8K7BfSHIDqzVQ2sdddNozbJjtg9SG/HLhYb03wFbWmsjMSdR7H8FtCXeCteNLHVyaqagAD+U9dSZzoPOJCzyE4NMjcc/Y3Gg77WpTduQOTVg6v5trLBpmmW8KPxgR8iPtEZHXZoudDs0cZUZitKtsVUx+Bg8FKmquJve2Wa0ZE3nvmZPHY59mU5aJ5o8WZ7CihUFnIxQJ7NZNf48ljHWQHysBZd5UzU8aq5FGY6cd7XYhz7odTKszzCBfyHHjijTU+hNtAinEAy4Wzis6znRkuNsM0Z+vwj8mULmbJLupo7XVtAETNhW4rR23zzd1DVT4bN1FWxTmBZnemqEAFX5D9Wli1gG/iNWQ8dDaGLn6GA7wgNsJXcY18a5Y9YOxbE01O/aLbehd4CbLA/u8UBRBUdvuq+/vEqeMlh8ShfjVtNPY6lpv5GLLM4bot4aL4rBvgq4WzboJZD7wJEJLVJVnsvGj0VUBKzMQjPI1vQjxdE5ZrOoyRIwCixt5TzQyXQ0NS05N7exKoF17HN+/d02pYg=
REGRESSION. Last worked in version 7u80
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Java 7 Code:
import sun.misc.BASE64Decoder; // once this gets fixed we are hoping to use java 8's Base64
/* Name of the class has to be "Main" only if the class is public. */
public class Main {
public static void main(String[] args) throws java.lang.Exception {
// your code goes here
String encodedString = "ohAmCN+16W4=";
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes;
decodedBytes = decoder.decodeBuffer(encodedString);
System.out.println(new String(decodedBytes, "UTF-8"));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
for base64 string ohAmCN+16W4=
?&??
ACTUAL -
for base64 string ohAmCN+16W4=
?&??n
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import sun.misc.BASE64Decoder; // once this gets fixed we are hoping to use java 8's Base64
/* Name of the class has to be "Main" only if the class is public. */
public class Main {
public static void main(String[] args) throws java.lang.Exception {
// your code goes here
String encodedString = "ohAmCN+16W4=";
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes;
decodedBytes = decoder.decodeBuffer(encodedString);
System.out.println(new String(decodedBytes, "UTF-8"));
}
}
---------- END SOURCE ----------