小工具整理

This commit is contained in:
Abin
2025-07-31 16:05:55 +08:00
commit 1011eb44e1
566 changed files with 267142 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
OpzeyetgcunSGXfRDPnbhvl4Y4U0n8oNolqvWh4xtwWHUoar5xpJGlx8WQ07J02/Xt9CH2qpPNBcO8Rep8GOxez8SUPzEw8xSQxpkHoIHvsdNiBDZCxQTZU5MaB/8SfuTESosGV3p5AQ2aqFaKrpGABBSGebgfL75uDHmSFq8ME=
+1
View File
@@ -0,0 +1 @@
<RSAKeyValue><Modulus>zyQ7zokCM/wHwJrb89hKyzC4LTPDCvR7qw8sIuJLGsbPJqJReTgAxxDyZNrIobDjO2M5OaCljSP2VDv6lxwMG8wNlyKoy5opBtWjUtZgc+/H54hppLGmgaWR3pYmojEomHw5gmFdAWZpz42yf3QO4ehYIVHuOpeXJpBpdEgrY2k=</Modulus><Exponent>AQAB</Exponent><P>4lUl/1Skw5S3xuXSh3gYzVQFyqAsrnJeENQxJ8Abx1PR2Gck+wkcadaqdRD+9sLeff9rsVwAObGAGzfQ2mBzow==</P><Q>6ksbSrCw14U2XOWrLyQynyodtHYBoMQRfS0uUTwJutCgb+Rfe56Lfv4nUXnC/GpiZkuXnZsKcLNvyB1PQtpdgw==</Q><DP>T3/xNNqadUiLtQWNCaCZtaXJ0v6oMy5g9DBUg83q8/zxPL4eMz9kB5krjqtFo4+Xb1KElWvneFxszyKv7cTrWQ==</DP><DQ>4oSO9F1z/Er8zj/2i3NRxfSwF4Nn+4jU59NAzqVfOtDt7IA9mIUmlTcfyHQSgnxQelpnUadOJrw1PKKpuRbqBQ==</DQ><InverseQ>IXxMkGm2cn7esrIdZBTXv8gOmV8DBP3ERleT3VBUfyR4Qa1uhJ8agGZdDm/TcLlte45uUHhgPJuSYvjLo7ZLBA==</InverseQ><D>yY2vKAtGeoC8plvIs998/3M7crhQC2PSxaKwxoy8maRjQmtkrXehwhEqWppL6JDuugWVVA6Np+UbNeFatxhSaiWRJJv0iccR0GyT38vWGbmN2FNew+2KsP/+2MDva3z8o5OZ+p0bsqUwiTL05z71zK/dd5tZHGhHmM4W3sMdbKU=</D></RSAKeyValue>
@@ -0,0 +1,35 @@
-- 使用私钥进行解密的函数
fn decryptWithPrivateKey encryptedData privateKey =
(
rsaProvider = dotnetobject "System.Security.Cryptography.RSACryptoServiceProvider"
rsaProvider.FromXmlString(privateKey)
methodprivatekey = (dotnetclass "System.Security.Cryptography.RSAEncryptionPadding").Pkcs1
try(
-- 使用私钥解密字节数组
decryptedBytes = rsaProvider.Decrypt encryptedData methodprivatekey
-- 将字节数组转换为文本
decryptedText = (dotnetclass "System.Text.Encoding").UTF8.GetString(decryptedBytes)
return decryptedText)catch(return "解密错误!!!")
)
-- 从文件中读取加密后的数据
encryptedDataFilePath = getFilenamePath(getThisScriptFilename()) + "data.txt"
streamReader = dotnetobject "System.IO.StreamReader" encryptedDataFilePath
encryptedData = (dotnetclass "System.Convert").FromBase64String(streamReader.ReadLine())
streamReader.Close()
-- 从文件中读取私钥
privateKeyFilePath = getFilenamePath(getThisScriptFilename()) + "privateKey.xml"
streamReader = dotnetobject "System.IO.StreamReader" privateKeyFilePath
privateKey = streamReader.ReadToEnd()
streamReader.Close()
-- 示例:使用私钥解密之前加密的数据
decryptedText = decryptWithPrivateKey encryptedData privateKey
-- 输出解密后的数据
print decryptedText
@@ -0,0 +1,44 @@
-- 使用非对称加密进行加密的函数
fn encryptWithPublicKey plaintext publicKey =
(
rsaProvider = dotnetobject "System.Security.Cryptography.RSACryptoServiceProvider"
rsaProvider.FromXmlString(publicKey)
methodpublickey = (dotnetclass "System.Security.Cryptography.RSAEncryptionPadding").Pkcs1
-- 将文本转换为字节数组
plaintextBytes = (dotnetclass "System.Text.Encoding").UTF8.GetBytes(plaintext)
-- 使用公钥加密字节数组
encryptedData = rsaProvider.Encrypt plaintextBytes methodpublickey
return encryptedData
)
-- 要加密的文字内容
plaintext = "我是机密,不能告诉其他人。"
-- 生成公钥和私钥
rsaProvider = dotnetobject "System.Security.Cryptography.RSACryptoServiceProvider"
publicKey = rsaProvider.ToXmlString(false)
privateKey = rsaProvider.ToXmlString(true)
-- 将私钥保存到文件
privateKeyFilePath = getFilenamePath(getThisScriptFilename()) +"privateKey.xml"
streamWriter = dotnetobject "System.IO.StreamWriter" privateKeyFilePath
streamWriter.WriteLine(privateKey)
streamWriter.Close()
-- 使用公钥加密
encryptedData = encryptWithPublicKey plaintext publicKey
-- 将加密后的字节数组转换为Base64字符串
encryptedDataString = (dotnetclass "System.Convert").ToBase64String(encryptedData)
-- 将加密后的数据保存到文件
encryptedDataFilePath = getFilenamePath(getThisScriptFilename()) +"data.txt"
streamWriter = dotnetobject "System.IO.StreamWriter" encryptedDataFilePath
streamWriter.WriteLine(encryptedDataString)
streamWriter.Close()