This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 8d7b0a35a8d Fix RC4EncryptAlgorithm with duplicated reset (#18203)
8d7b0a35a8d is described below
commit 8d7b0a35a8df78b683d077ba11327c6b4db2a17e
Author: cheese8 <[email protected]>
AuthorDate: Tue Jun 7 10:54:25 2022 +0800
Fix RC4EncryptAlgorithm with duplicated reset (#18203)
* Update RC4EncryptAlgorithm.java
* Update RC4EncryptAlgorithmTest.java
---
.../shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java | 6 +-----
.../shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java | 4 ++--
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
index f0e5e6fe66d..ba3a2193ce2 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
@@ -74,11 +74,7 @@ public final class RC4EncryptAlgorithm implements
EncryptAlgorithm<Object, Strin
}
private byte[] handle(final byte[] data, final byte[] key) {
- reset();
- setKey(key);
- byte[] result = crypt(data);
- reset();
- return result;
+ return crypt(data);
}
private void reset() {
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
index 1db7865b20f..e922e4e0b18 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
@@ -49,7 +49,7 @@ public final class RC4EncryptAlgorithmTest {
@Test
public void assertEncode() {
- assertThat(encryptAlgorithm.encrypt("test",
mock(EncryptContext.class)), is("qn36NQ=="));
+ assertThat(encryptAlgorithm.encrypt("test",
mock(EncryptContext.class)), is("4Tn7lQ=="));
}
@Test
@@ -74,7 +74,7 @@ public final class RC4EncryptAlgorithmTest {
@Test
public void assertDecode() {
- assertThat(encryptAlgorithm.decrypt("qn36NQ==",
mock(EncryptContext.class)).toString(), is("test"));
+ assertThat(encryptAlgorithm.decrypt("4Tn7lQ==",
mock(EncryptContext.class)).toString(), is("test"));
}
@Test