Skip to content

Commit 5e73651

Browse files
committed
Took substring of public key and created buffer in XOR
Signed-off-by: S V <vats02581@gmail.com>
1 parent 426223d commit 5e73651

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/authentication/MySqlAuthProvider.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,10 @@ static byte[] rsaEncryption(byte[] bytesToEncrypt, String serverRsaPublicKeyFile
158158

159159
String key = new String(Files.readAllBytes(Paths.get(serverRsaPublicKeyFile)), Charset.defaultCharset());
160160

161-
int startIndex = key.indexOf("-----BEGIN PUBLIC KEY-----");
162-
int endIndex = key.indexOf("-----END PUBLIC KEY-----") + 23;
163-
key = key.substring(startIndex, endIndex + 1);
164-
String publicKeyPEM = key
165-
.replace("-----BEGIN PUBLIC KEY-----", "")
166-
.replaceAll(System.lineSeparator(), "")
167-
.replace("-----END PUBLIC KEY-----", "");
161+
int startIndex = key.indexOf("-----BEGIN PUBLIC KEY-----") + 26;
162+
int endIndex = key.indexOf("-----END PUBLIC KEY-----");
163+
key = key.substring(startIndex, endIndex);
164+
String publicKeyPEM = key.replaceAll(System.lineSeparator(), "");
168165

169166
byte[] encoded = Base64.getDecoder().decode(publicKeyPEM);
170167

0 commit comments

Comments
 (0)