Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
Solar Master Ace
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Solar Master Ace
Commits
c9c7fd97
Commit
c9c7fd97
authored
Mar 22, 2024
by
maxiaoliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d19fe96c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
141 deletions
+0
-141
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-1
MyApplicaiton.kt
app/src/main/java/com/zxhy/solarmasterace/MyApplicaiton.kt
+0
-14
AESHelper.kt
app/src/main/java/com/zxhy/solarmasterace/tools/AESHelper.kt
+0
-58
AESTextView.kt
...rc/main/java/com/zxhy/solarmasterace/tools/AESTextView.kt
+0
-15
KotlinExt.kt
app/src/main/java/com/zxhy/solarmasterace/tools/KotlinExt.kt
+0
-53
No files found.
app/src/main/AndroidManifest.xml
View file @
c9c7fd97
...
...
@@ -9,7 +9,6 @@
tools:ignore=
"ScopedStorage"
/>
<application
android:name=
".MyApplicaiton"
android:allowBackup=
"true"
android:dataExtractionRules=
"@xml/data_extraction_rules"
android:fullBackupContent=
"@xml/backup_rules"
...
...
app/src/main/java/com/zxhy/solarmasterace/MyApplicaiton.kt
deleted
100644 → 0
View file @
d19fe96c
package
com.zxhy.solarmasterace
import
android.app.Application
class
MyApplicaiton
:
Application
()
{
companion
object
{
lateinit
var
context
:
MyApplicaiton
}
override
fun
onCreate
()
{
super
.
onCreate
()
context
=
this
}
}
\ No newline at end of file
app/src/main/java/com/zxhy/solarmasterace/tools/AESHelper.kt
deleted
100644 → 0
View file @
d19fe96c
package
com.zxhy.solarmasterace.tools
import
android.util.Base64
import
java.security.SecureRandom
import
javax.crypto.Cipher
import
javax.crypto.spec.GCMParameterSpec
import
javax.crypto.spec.SecretKeySpec
object
AESHelper
{
private
const
val
aesKey
=
""
private
val
cipher
by
lazy
{
Cipher
.
getInstance
(
"AES/GCM/NoPadding"
)
}
fun
encrypt
(
content
:
String
):
String
{
try
{
val
iv
=
ByteArray
(
12
).
apply
{
SecureRandom
().
nextBytes
(
this
)
}
val
contentBytes
=
content
.
toByteArray
(
Charsets
.
UTF_8
)
val
params
=
GCMParameterSpec
(
128
,
iv
)
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
,
params
)
val
encryptData
=
cipher
.
doFinal
(
contentBytes
)
assert
(
encryptData
.
size
==
contentBytes
.
size
+
16
)
val
message
=
ByteArray
(
12
+
contentBytes
.
size
+
16
)
System
.
arraycopy
(
iv
,
0
,
message
,
0
,
12
)
System
.
arraycopy
(
encryptData
,
0
,
message
,
12
,
encryptData
.
size
)
return
String
(
Base64
.
encode
(
message
,
Base64
.
NO_WRAP
),
Charsets
.
UTF_8
)
}
catch
(
_
:
Exception
)
{
}
return
content
}
@Synchronized
fun
decrypt
(
content
:
String
):
String
{
try
{
val
con
=
content
.
replace
(
" "
.
toRegex
(),
"+"
)
val
contentByte
=
Base64
.
decode
(
con
,
Base64
.
NO_WRAP
)
require
(
contentByte
.
size
>=
12
+
16
)
val
params
=
GCMParameterSpec
(
128
,
contentByte
,
0
,
12
)
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
params
)
val
decryptData
=
cipher
.
doFinal
(
contentByte
,
12
,
contentByte
.
size
-
12
)
return
String
(
decryptData
,
Charsets
.
UTF_8
)
}
catch
(
_
:
Exception
)
{
}
return
content
}
private
val
secretKey
by
lazy
{
SecretKeySpec
(
aesKey
.
toByteArray
(),
"AES"
)
}
}
\ No newline at end of file
app/src/main/java/com/zxhy/solarmasterace/tools/AESTextView.kt
deleted
100644 → 0
View file @
d19fe96c
package
com.zxhy.solarmasterace.tools
import
android.content.Context
import
android.util.AttributeSet
import
com.zxhy.solarmasterace.tools.KotlinExt.decode
class
AESTextView
@JvmOverloads
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
)
:
androidx
.
appcompat
.
widget
.
AppCompatTextView
(
context
,
attrs
)
{
override
fun
setText
(
text
:
CharSequence
?,
type
:
BufferType
?)
{
super
.
setText
(
text
?.
toString
().
takeIf
{
it
!=
it
?.
decode
()
}
?.
decode
()
?:
text
,
type
)
}
}
\ No newline at end of file
app/src/main/java/com/zxhy/solarmasterace/tools/KotlinExt.kt
deleted
100644 → 0
View file @
d19fe96c
package
com.zxhy.solarmasterace.tools
import
android.view.View
import
com.zxhy.solarmasterace.MyApplicaiton
import
java.text.SimpleDateFormat
import
java.util.Locale
object
KotlinExt
{
private
val
aesMap
=
mutableMapOf
<
Int
,
String
>()
fun
Int
.
string
(
vararg
arg
:
Any
)
=
try
{
(
aesMap
[
this
]
?:
MyApplicaiton
.
context
.
getString
(
this
).
decode
()).
run
{
aesMap
[
this
@string
]
=
this
String
.
format
(
this
,
*
arg
)
}
}
catch
(
_
:
Exception
)
{
""
}
fun
String
.
decode
()
=
AESHelper
.
decrypt
(
this
)
.
replace
(
"\\n"
,
"\n"
)
.
replace
(
"\\'"
,
"'"
)
.
replace
(
"\\?"
,
"?"
)
.
replace
(
"&"
,
"&"
)
fun
Collection
<
View
>.
setOnClickListener
(
listener
:
(
View
)
->
Unit
)
{
this
.
forEach
{
it
.
setOnClickListener
(
listener
)
}
}
fun
Number
.
toFormatSize
(
count
:
Int
=
2
):
String
{
var
suffix
=
"B"
var
fSize
=
this
.
toDouble
()
if
(
fSize
>
1024
)
{
suffix
=
"KB"
fSize
/=
1024.0
}
if
(
fSize
>
1024
)
{
suffix
=
"MB"
fSize
/=
1024.0
}
if
(
fSize
>
1024
)
{
suffix
=
"GB"
fSize
/=
1024.0
}
return
String
.
format
(
"%.${count}f %s"
,
fSize
,
suffix
)
}
fun
Long
.
toFormatTime
():
String
{
return
SimpleDateFormat
(
"MMM dd,yyyy"
,
Locale
.
getDefault
()).
format
(
this
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment