86 lines
2.4 KiB
C#
86 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using WpfApp1.Util;
|
|
|
|
public class Test : MonoBehaviour
|
|
{
|
|
public InputField InputField_ase;
|
|
public Button encryption_aes_bt;
|
|
public Button decrypt_aes_bt;
|
|
public InputField InputField_ase2;
|
|
|
|
public InputField InputField_rsa;
|
|
public Button decrypt_rsa_bt;
|
|
public Text text_rsa;
|
|
|
|
public string s2 => "";
|
|
|
|
public string key;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
//string s1 = "EABh1w13fBqFX9uVZkzOcJ2bDPHhqNjb3NnEInnfp/h/ZhbR9ElNBWAEmJeyfQC+zmnzrzzrRX+qNSTLJyoIySWZPCAMPXW1N8IAXV6cVJlnEsWaSeFJqnd5kwED6Ex1oBBUvQF3QT8t/6V6CWQRc3xTc2r5TIOhyWwxanW3Gxg=";
|
|
// s2 = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCXLr8EzT/lt9XYKOX2CzkwqVcW//UyIP5824OEgdPHLhBvGy5QXtyIj0myw3LlbqZkOoX8SZFMxJOnHiCKIVhXrTYOaxTdWYv95DR4gCZ9q55U7NQPUkeMtTbuLa5HHdpBy8DM+DfS2VJv6RTK3AJLjWkNjpyhGgWIlOTGbMsj7QIDAQAB";
|
|
//var ss = RSAHelper.DecryptByPublicKey(s1, s2);
|
|
//Debug.Log(ss);
|
|
|
|
|
|
|
|
|
|
//var aa = AESHelper.AesEncrypt("µÄÈö½¿", ss);
|
|
//Debug.Log(aa);
|
|
|
|
//var bb = AESHelper.AesDecrypt(aa, ss);
|
|
//Debug.Log(bb);
|
|
|
|
encryption_aes_bt.onClick.AddListener(() =>
|
|
{
|
|
if (InputField_ase != null && !string.IsNullOrEmpty(InputField_ase.text) && !string.IsNullOrEmpty(key))
|
|
{
|
|
var ss = AESHelper.AesEncrypt(InputField_ase.text, key);
|
|
InputField_ase2.text = ss;
|
|
}
|
|
else
|
|
{
|
|
key = string.Empty;
|
|
return;
|
|
}
|
|
|
|
});
|
|
|
|
decrypt_aes_bt.onClick.AddListener(() =>
|
|
{
|
|
if (InputField_ase2 != null && !string.IsNullOrEmpty(InputField_ase2.text) && !string.IsNullOrEmpty(key))
|
|
{
|
|
var ss = AESHelper.AesDecrypt(InputField_ase2.text, key);
|
|
InputField_ase.text = ss;
|
|
}
|
|
else
|
|
return;
|
|
});
|
|
|
|
|
|
|
|
|
|
decrypt_rsa_bt.onClick.AddListener(() =>
|
|
{
|
|
if (InputField_rsa != null && !string.IsNullOrEmpty(InputField_rsa.text))
|
|
{
|
|
var ss = RSAHelper.DecryptByPublicKey(InputField_rsa.text, s2);
|
|
text_rsa.text = ss;
|
|
key = ss;
|
|
}
|
|
else
|
|
return;
|
|
});
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|