Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit ee4bd0a

Browse files
合并部分代码
1 parent 10b8669 commit ee4bd0a

25 files changed

Lines changed: 79 additions & 87 deletions

build.gradle.kts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
group = "com.github.OpenEDGN.GradleKotlinTemplate"
2-
// 你可以修改此为自己的组织地址
3-
version = "last"
4-
// 你可以指定此为项目 版本号
1+
group = "com.github.OpenEDGN.Security4K"
52

63
buildscript {
7-
repositories{
4+
repositories {
85
mavenLocal()
96
maven { url = project.uri("https://maven.aliyun.com/repository/public/") }
10-
jcenter()
117
mavenCentral()
128
maven { url = project.uri("https://jitpack.io") }
139
}
@@ -17,13 +13,13 @@ buildscript {
1713
}
1814

1915
allprojects {
20-
repositories{
16+
repositories {
2117
mavenLocal()
2218
maven { url = project.uri("https://maven.aliyun.com/repository/public/") }
23-
jcenter()
2419
mavenCentral()
2520
maven { url = project.uri("https://jitpack.io") }
26-
}}
21+
}
22+
}
2723

2824
tasks.register("clean", Delete::class) {
2925
delete(rootProject.buildDir)

core/build.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ dependencies {
1919
implementation(kotlin("stdlib"))
2020
testImplementation("com.github.OpenEdgn.Logger4K:core:1.3.1")
2121
testImplementation("com.github.OpenEdgn.Logger4K:logger-console:1.3.1")
22-
testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
23-
testImplementation("org.junit.platform:junit-platform-launcher:1.6.2")
22+
testImplementation("org.junit.jupiter:junit-jupiter:5.7.2")
23+
testImplementation("org.junit.platform:junit-platform-launcher:1.7.2")
2424
}
2525

2626
tasks.test {
@@ -51,6 +51,3 @@ publishing {
5151
mavenLocal()
5252
}
5353
}
54-
55-
56-

core/src/main/kotlin/com/github/open_edgn/security4k/asymmetric/rsa/RSA.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.github.open_edgn.security4k.asymmetric.rsa
22

3-
import com.github.open_edgn.security4k.asymmetric.universal.Decoder
4-
import com.github.open_edgn.security4k.asymmetric.universal.Encoder
53
import com.github.open_edgn.security4k.base64.Base64Utils
4+
import com.github.open_edgn.security4k.universal.Decoder
5+
import com.github.open_edgn.security4k.universal.Encoder
66
import com.github.open_edgn.security4k.utils.foreach
77
import java.io.ByteArrayOutputStream
88
import java.io.InputStream
@@ -36,7 +36,6 @@ abstract class RSA(
3636
private val encryptedBlockSize by lazy { newInitCipher(Cipher.ENCRYPT_MODE).getOutputSize(1) }
3737
private val maxBlockSize: Int by lazy { encryptedBlockSize - 11 }
3838

39-
4039
protected val transformation: String = "RSA"
4140

4241
/**
@@ -57,7 +56,6 @@ abstract class RSA(
5756
return cipher
5857
}
5958

60-
6159
private fun doFinal(input: InputStream, output: OutputStream, mode: Int, bufferSize: Int) {
6260
val cipher = newInitCipher(mode)
6361
val blockOutput = ByteArray(bufferSize * 4)
@@ -87,4 +85,4 @@ abstract class RSA(
8785
encode(plainText.toByteArray(charset).inputStream(), stream)
8886
return Base64Utils.encodeBytes(stream.toByteArray(), true)
8987
}
90-
}
88+
}

core/src/main/kotlin/com/github/open_edgn/security4k/asymmetric/rsa/RsaKeyGenerator.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import java.security.interfaces.RSAPublicKey
1717
* @param random SecureRandom 随机数生成器
1818
* @constructor
1919
*/
20-
class RsaKeyGenerator
21-
(
20+
class RsaKeyGenerator(
2221
keySize: Int = 2048,
2322
random: SecureRandom = SecureRandom.getInstanceStrong()
2423
) : KeyGenerator {
@@ -40,5 +39,4 @@ class RsaKeyGenerator
4039
override val privateKeyText: String by lazy {
4140
Base64Utils.encodeBytes(privateKey.encoded, true)
4241
}
43-
44-
}
42+
}

core/src/main/kotlin/com/github/open_edgn/security4k/asymmetric/rsa/RsaPrivate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ class RsaPrivate(
4747
signature.initSign(privateK)
4848
return signature
4949
}
50-
}
50+
}

core/src/main/kotlin/com/github/open_edgn/security4k/asymmetric/rsa/RsaPublic.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ class RsaPublic(
4646
signature.initVerify(publicK)
4747
return signature
4848
}
49-
}
49+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.github.open_edgn.security4k.asymmetric.universal
22

3+
import com.github.open_edgn.security4k.universal.Encrypt
4+
35
/**
46
* 非对称加、解密中私钥的接口
57
*/
6-
interface IPrivateKey : Encoder, Decoder, Sign {
7-
8-
}
8+
interface IPrivateKey : Encrypt, Sign
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.github.open_edgn.security4k.asymmetric.universal
22

3+
import com.github.open_edgn.security4k.universal.Encrypt
4+
35
/**
46
* 非对称加解密中公钥接口
57
*/
6-
interface IPublicKey : Decoder, Encoder, Verify {
7-
}
8+
interface IPublicKey : Encrypt, Verify

core/src/main/kotlin/com/github/open_edgn/security4k/asymmetric/universal/KeyGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ interface KeyGenerator {
1313
* 私钥文本
1414
*/
1515
val privateKeyText: String
16-
}
16+
}

core/src/main/kotlin/com/github/open_edgn/security4k/asymmetric/universal/Sign.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,4 @@ interface Sign {
4343
* @return String 签名
4444
*/
4545
fun signText(data: String, charset: Charset = Charsets.UTF_8): String
46-
47-
48-
}
46+
}

0 commit comments

Comments
 (0)