Hi Team
How can achieve same output when writing a c# encryption? I have a vb.net console app that does the same, but the problem the output are not the same with c# console app and want the output when a user insert any string text for their password the decryption be same with c# console.
Imports System Namespace Decryption Class Program Shared Sub Main(args As String()) Console.WriteLine("Enter the encrypted text:") Dim encryptedText As String = Console.ReadLine() Dim decryptedText As String = Decrypt(encryptedText) Console.WriteLine("Decrypted Text: " & decryptedText) End Sub Shared Function Decrypt(encryptedText As String) As String Dim pi As Double = 3.1415927 Dim temp As String = "" Dim h As Integer = 0 Dim decryptedText As String = "" ' Decrypting loop For i As Integer = 0 To encryptedText.Length - 1 Dim tempCharValue As Double = Math.Sin((AscW(Char.ToLower(encryptedText(i))) - AscW("a"c)) / 26.0 * pi) * Math.Cos((i + 1) / CDbl(encryptedText.Length) * 0.25 * pi) * 25 + AscW("a"c) temp += ChrW(If(tempCharValue >= AscW("a"c), tempCharValue, tempCharValue + 26)) h += AscW(temp(temp.Length - 1)) Next For i As Integer = 0 To encryptedText.Length - 1 Dim charValue As Double = AscW("a"c) + ((AscW(Char.ToLower(temp(i))) - AscW("a"c) - h) + 26) Mod 26 decryptedText += ChrW(If(charValue >= AscW("a"c), charValue, charValue + 26)) Next Return decryptedText End Function End Class End Namespace // C# console app. using System; namespace Decryption { class Program { static void Main(string[] args) { Console.WriteLine("Enter the encrypted text:"); string encryptedText = Console.ReadLine(); string decryptedText = Decrypt(encryptedText); Console.WriteLine("Decrypted Text: " + decryptedText); } static string Decrypt(string encryptedText) { double pi = 3.1415927; string temp = ""; int h = 0; string decryptedText = ""; for (int i = 0; i < encryptedText.Length; i++) { double tempCharValue = Math.Sin((Convert.ToInt32(char.ToLower(encryptedText[i])) - Convert.ToInt32('a')) / 26.0 * pi) * Math.Cos((i + 1) / (double)encryptedText.Length * 0.25 * pi) * 25 + Convert.ToInt32('a'); temp += (char)(tempCharValue >= 'a' ? tempCharValue : tempCharValue + 26); h += Convert.ToInt32(temp[temp.Length - 1]); } for (int i = 0; i < encryptedText.Length; i++) { double charValue = 'a' + ((Convert.ToInt32(char.ToLower(temp[i])) - 'a' - h) + 26) % 26; decryptedText += (char)(charValue >= 'a' ? charValue : charValue + 26); } return decryptedText; } } }