//Mã hóa đối xứng Secretkey = Public Key truyền vào trực tiếp ko đọc File public void EncryptSecretKeyWithRSAAlgo_DirectPublicKey(string publicKey, int KeySize) { MyRSAAlgorithm myRSA = new MyRSAAlgorithm(); myRSA.SetKeyLength(KeySize); m_EncryptedSecretKey = myRSA.EncryptData(m_SecretKey, publicKey); }
//Mã hóa bất đối xứng secretkey = public key public void EncryptSecretKeywithASAlgorithm(String inputPublicFile) { //Tạo RSA ra, set chiều dài, đọc file Input Public, gán vào và mã hóa, trả về StreamReader srReader = new StreamReader(inputPublicFile); int KeyLength = int.Parse(srReader.ReadLine()); string ReadKey = srReader.ReadLine(); srReader.Close(); MyRSAAlgorithm myRSA = new MyRSAAlgorithm(); myRSA.SetKeyLength(KeyLength); m_EncryptedSecretKey = myRSA.EncryptData(m_SecretKey, ReadKey); }