Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix code scan #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/main/java/tech/shiker/common/Result.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tech.shiker.common;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import java.security.spec.AlgorithmParameterSpec;

public class Result {
private final SecretKey secretKey;

private final AlgorithmParameterSpec paramSpec;

private final Cipher cipher;

public Result(SecretKey secretKey, AlgorithmParameterSpec paramSpec, Cipher cipher) {
this.secretKey = secretKey;
this.paramSpec = paramSpec;
this.cipher = cipher;
}

public SecretKey secretKey() {
return secretKey;
}

public AlgorithmParameterSpec paramSpec() {
return paramSpec;
}

public Cipher cipher() {
return cipher;
}
}
26 changes: 25 additions & 1 deletion src/main/java/tech/shiker/enccore/DecryptResult.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
package tech.shiker.enccore;

public record DecryptResult(String decryptStr, boolean isDecryptError, String message) {
public class DecryptResult {

private final String decryptStr;
;

private final boolean isDecryptError;

private final String message;

public DecryptResult(String decryptStr, boolean isDecryptError, String message) {
this.decryptStr = decryptStr;
this.isDecryptError = isDecryptError;
this.message = message;
}

public String decryptStr() {
return decryptStr;
}

public boolean isDecryptError() {
return isDecryptError;
}

public String message() {
return message;
}
}
27 changes: 26 additions & 1 deletion src/main/java/tech/shiker/enccore/EncryptResult.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
package tech.shiker.enccore;

public record EncryptResult (String encryptStr, boolean isEncryptError, String message){
public class EncryptResult {

private final String encryptStr;
;

private final boolean isEncryptError;

private final String message;

public EncryptResult(String encryptStr, boolean isEncryptError, String message) {
this.encryptStr = encryptStr;
this.isEncryptError = isEncryptError;
this.message = message;
}

public String encryptStr() {
return encryptStr;
}

public boolean isEncryptError() {
return isEncryptError;
}

public String message() {
return message;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tech.shiker.security.impl;

import org.jetbrains.annotations.NotNull;
import tech.shiker.common.Result;
import tech.shiker.common.SecurityConstant;
import tech.shiker.common.SecurityInfo;
import tech.shiker.enccore.DecryptResult;
Expand Down Expand Up @@ -75,7 +76,4 @@ private Result getSecurityCipherInfo(String key, String index, String salt, Inte
Cipher cipher = Cipher.getInstance(securityInfo.decryptInformation());
return new Result(secretKey, paramSpec, cipher);
}

private record Result(SecretKey secretKey, AlgorithmParameterSpec paramSpec, Cipher cipher) {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tech.shiker.security.impl;

import org.jetbrains.annotations.NotNull;
import tech.shiker.common.Result;
import tech.shiker.common.SecurityConstant;
import tech.shiker.common.SecurityInfo;
import tech.shiker.enccore.DecryptResult;
Expand Down Expand Up @@ -65,10 +66,6 @@ private Result getSecurityCipherInfo(String key, String salt, Integer iterations
return new Result(secretKey, paramSpec, cipher);
}

private record Result(SecretKey secretKey, AlgorithmParameterSpec paramSpec, Cipher cipher) {
}


@Override
public EncryptResult encrypt(String src, String key, String index, String salt, Integer iterations) throws Exception {
return encrypt(src, key, salt, iterations);
Expand Down
Loading