Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
tuseGameColor
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
shujianhe
tuseGameColor
Commits
f1ae6f68
Commit
f1ae6f68
authored
Aug 23, 2023
by
JiangWanZhi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.huolea.com:shujianhe/tusegamecolor
parents
0d357371
89d7e213
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
PassWordMgr.cs
Assets/GameMgr/PassWordMgr.cs
+71
-0
PassWordMgr.cs.meta
Assets/GameMgr/PassWordMgr.cs.meta
+11
-0
No files found.
Assets/GameMgr/PassWordMgr.cs
0 → 100644
View file @
f1ae6f68
using
System
;
using
System.Collections
;
using
System.IO
;
using
System.Security.Cryptography
;
using
System.Text
;
using
UnityEngine
;
public
class
PassWordMgr
{
public
const
string
Key
=
"zhangxinhulianxx"
;
public
const
string
IV
=
"lijinlijinlijinx"
;
public
static
string
EncryptString
(
string
plainText
)
{
if
(
plainText
==
null
||
plainText
.
Length
<=
0
)
throw
new
ArgumentNullException
(
"plainText"
);
if
(
Key
==
null
||
Key
.
Length
<=
0
)
throw
new
ArgumentNullException
(
"Key"
);
if
(
IV
==
null
||
IV
.
Length
<=
0
)
throw
new
ArgumentNullException
(
"IV"
);
byte
[]
encrypted
;
using
(
Aes
aesAlg
=
Aes
.
Create
())
{
aesAlg
.
Key
=
Encoding
.
ASCII
.
GetBytes
(
Key
);
aesAlg
.
IV
=
Encoding
.
ASCII
.
GetBytes
(
IV
);
ICryptoTransform
encryptor
=
aesAlg
.
CreateEncryptor
(
aesAlg
.
Key
,
aesAlg
.
IV
);
using
(
MemoryStream
msEncrypt
=
new
MemoryStream
())
{
using
(
CryptoStream
csEncrypt
=
new
CryptoStream
(
msEncrypt
,
encryptor
,
CryptoStreamMode
.
Write
))
{
using
(
StreamWriter
swEncrypt
=
new
StreamWriter
(
csEncrypt
,
Encoding
.
UTF8
))
{
swEncrypt
.
Write
(
plainText
);
}
encrypted
=
msEncrypt
.
ToArray
();
}
}
}
return
Convert
.
ToBase64String
(
encrypted
);
}
public
static
string
DecryptString
(
string
cipherStr
)
{
var
cipherText
=
Convert
.
FromBase64String
(
cipherStr
);
if
(
cipherText
==
null
||
cipherText
.
Length
<=
0
)
throw
new
ArgumentNullException
(
"cipherText"
);
if
(
Key
==
null
||
Key
.
Length
<=
0
)
throw
new
ArgumentNullException
(
"Key"
);
if
(
IV
==
null
||
IV
.
Length
<=
0
)
throw
new
ArgumentNullException
(
"IV"
);
string
plaintext
=
null
;
using
(
Aes
aesAlg
=
Aes
.
Create
())
{
aesAlg
.
Key
=
Encoding
.
ASCII
.
GetBytes
(
Key
);
aesAlg
.
IV
=
Encoding
.
ASCII
.
GetBytes
(
IV
);
ICryptoTransform
decryptor
=
aesAlg
.
CreateDecryptor
(
aesAlg
.
Key
,
aesAlg
.
IV
);
using
(
MemoryStream
msDecrypt
=
new
MemoryStream
(
cipherText
))
{
using
(
CryptoStream
csDecrypt
=
new
CryptoStream
(
msDecrypt
,
decryptor
,
CryptoStreamMode
.
Read
))
{
using
(
StreamReader
srDecrypt
=
new
StreamReader
(
csDecrypt
,
Encoding
.
UTF8
))
{
plaintext
=
srDecrypt
.
ReadToEnd
();
}
}
}
}
return
plaintext
;
}
}
\ No newline at end of file
Assets/GameMgr/PassWordMgr.cs.meta
0 → 100644
View file @
f1ae6f68
fileFormatVersion: 2
guid: 383a471e4afc4d043baa11dd343176f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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