public void Decrypt_EncryptedSamePlainTextSamePassword_SameEncryptionResults() { Decrypter decrypter = new Decrypter(); string cypherText1 = "bJ3jvVY7JuLAXaSa+YOyX+LCJwf/vqOoNYqTtfXrb1MuIOCXBBWjrXEURB/mEA46QwxX+yflecDqksWFzIdiuk1V2CGToV0gNOPrxYpu9n+1aeBhJuHQ163B0Lvv8n8+yNkTAsF/+X0nNVi00KLBwQ=="; string cypherText2 = "sGUsDTz8pN6EH9GP46fX07ZdPKbDhajJxuvYH8IRCPsFbx6wbAlyMuOMUOrzB7zCWs8vx0UFs399RV9k2RBk2zYVHM2MKVzuw4X7SzWoO0ufY47i2hFyB4cpf9PMCADv83Q5cB+TK+UajCaTd/6W8Q=="; string passPhrase = "Password"; string decryptedString1 = decrypter.Decrypt(cypherText1, passPhrase); string decryptedString2 = decrypter.Decrypt(cypherText2, passPhrase); string plainText = "This is a secret. \n Please do not read if you are not authorized"; Assert.Equal(plainText, decryptedString1); Assert.Equal(plainText, decryptedString2); }
public static License GetProductKey() { if (File.Exists(Environment.SystemDirectory.ToString() + "/tdhash")) { StreamReader tr = new StreamReader(Environment.SystemDirectory.ToString() + "/tdhash"); string productKey = ""; if ((productKey = tr.ReadLine()) != null) { productKey = Decrypter.Decrypt(productKey); ProductKeyHandler productKeyHandler = new ProductKeyHandler(productKey, productCode, version); if (productKeyHandler.IsValidProductKey()) { License license = new License(); license.ExpireDate = productKeyHandler.GetExpireDate(); license.LicenseType = productKeyHandler.GetLicenseType(); tr.Close(); return(license); } } tr.Close(); } return(null); }
public static string[] SubEncryption(string value) { string[] result = new string[2]; result[0] = Encrypter.Encrypt(value); result[1] = Decrypter.Decrypt(result[0]); return(result); }
public async Task <IActionResult> DownloadVideo(string file) { var userRootPath = ResolveUserRootPath(); var base64EncodedBytes = System.Convert.FromBase64String(file); var appPath = System.Text.Encoding.UTF8.GetString(base64EncodedBytes); appPath = UnifyAppPath(appPath); var path = Path.Combine(userRootPath, appPath); byte[] fileBytes; if (_useEncryption) { using var decryptedFileStream = await Decrypter.Decrypt(path, _certPath); fileBytes = decryptedFileStream.ToArray(); } else { fileBytes = System.IO.File.ReadAllBytes(path); } return(new FileContentResult(fileBytes, "video/mp4")); }
private void Decrypt(string password) { if (!Helpers.IsImage(ImagePath)) { return; } var backendThread = new Thread(() => DecryptText = Decrypter.Decrypt(ref imagePath, ref password)); backendThread.Start(); new Thread(() => { ButtonEnabled = false; while (backendThread.ThreadState == ThreadState.Running) { ButtonText = "Pracuji..."; } ButtonEnabled = true; ButtonText = "Rozšifruj"; }).Start(); }
public static List <string> ReadFile_skilldata() { List <string> listFileData = new List <string>(); string path = Environment.CurrentDirectory + @"\Media\server_dep\silkroad\textdata\skilldata.txt"; if (!File.Exists(path)) { throw new Exception("File \"skilldata.txt\" is not exist."); } using (TextReader reader = File.OpenText(path)) { string input = ""; while ((input = reader.ReadLine()) != null) { string temp = Environment.CurrentDirectory + @"\Media\server_dep\silkroad\textdata\" + input; if (File.Exists(temp)) { Decrypter.Decrypt(input); listFileData.Add(temp); } } } return(listFileData); }
public void Decrypt_EncryptWithWrongPassword_WrongResult() { Decrypter decrypter = new Decrypter(); string cypherText = "bJ3jvVY7JuLAXaSa+YOyX+LCJwf/vqOoNYqTtfXrb1MuIOCXBBWjrXEURB/mEA46QwxX+yflecDqksWFzIdiuk1V2CGToV0gNOPrxYpu9n+1aeBhJuHQ163B0Lvv8n8+yNkTAsF/+X0nNVi00KLBwQ=="; string wrongPassPhrase = "Password111"; string plainText = "This is a secret. \n Please do not read if you are not authorized"; Assert.NotEqual(plainText, decrypter.Decrypt(cypherText, wrongPassPhrase)); }
/// <summary> /// Implementation of slot. /// </summary> /// <param name="signaler">Signaler invoking slot.</param> /// <param name="input">Arguments to slot.</param> public void Signal(ISignaler signaler, Node input) { // Retrieving message and other arguments. var arguments = Utilities.GetArguments(input, true, "private-key"); // Decrypting message. var decrypter = new Decrypter(arguments.Key); var result = decrypter.Decrypt(arguments.Message); // Returning results to caller according to specifications. input.Value = arguments.Raw ? (object)result : Encoding.UTF8.GetString(result); }
/// <summary> /// Implementation of slot. /// </summary> /// <param name="signaler">Signaler invoking slot.</param> /// <param name="input">Arguments to slot.</param> public void Signal(ISignaler signaler, Node input) { // Retrieving arguments. var arguments = Utilities.GetArguments(input, true); // Performing actual decryption. var decrypter = new Decrypter(arguments.Password); var result = decrypter.Decrypt(arguments.Message); // Returning results to caller according to specifications. input.Value = arguments.Raw ? (object)result : Encoding.UTF8.GetString(result); }
//debug private void debug_Button_Click(object sender, RoutedEventArgs e) { var a = "abcdefghi"; var b = splice(a, 2); Debug.SaveFile(b + "", "arrrayle"); b = swap(a, 2); Debug.SaveFile(b + "", "arrrayle1"); b = rev(a); Debug.SaveFile(b + "", "arrrayle2"); var format = JObject.Parse(SelectedFormat.ToString()); string signature = format["signatureCipher"].ToString(); JObject signatureCipher = JsonHelper.ConvertToJson(signature); Decrypter.Decrypt(signatureCipher, SVD); }
/// <summary> /// Implementation of slot. /// </summary> /// <param name="signaler">Signaler invoking slot.</param> /// <param name="input">Arguments to slot.</param> public void Signal(ISignaler signaler, Node input) { // Retrieving arguments. var arguments = GetArguments(input); // Decrypting content. var decrypter = new Decrypter(arguments.DecryptionKey); var result = decrypter.Decrypt(arguments.Content); // Verifying content, but only if caller supplied a [verify-key]. if (arguments.VerifyKey != null && arguments.VerifyKey.Length > 0) { // Caller passed in a public key to verify the signature of message. var verifier = new Verifier(arguments.VerifyKey); result = verifier.Verify(result); // Returning result to caller. if (arguments.Raw) { input.Value = result; } else { input.Value = Encoding.UTF8.GetString(result); } } else { // Returning result to caller. // Notice, package is still "raw" since signature hasn't been verified yet. if (arguments.Raw) { input.Value = result; } else { input.Value = Convert.ToBase64String(result); } } }
public string Decrypt(MethodDef caller, int magic) { return(decrypter.Decrypt(caller, magic)); }
private static IEnumerable <Skill> LoadSkillsData() { foreach (var data in _reader.GetFileText("skilldata.txt").Split('\n').Select(line => line.Trim()).Where(line => !string.IsNullOrEmpty(line) && _reader.FileExists(line)).SelectMany(ft => _reader.GetFileText(ft).Split('\n').Where(line => !string.IsNullOrEmpty(line)).Select(line => line.Trim().Split('\t')))) { yield return(new Skill(data, SkillNames.ContainsKey(data[62]) ? SkillNames[data[62]] : "")); } foreach (var data in _reader.GetFileText("skilldataenc.txt").Split('\n').Select(line => line.Trim()).Where(line => !string.IsNullOrEmpty(line) && _reader.FileExists(line)).SelectMany(ft => Decrypter.Decrypt(_reader.GetFileStream(ft)).Split('\n').Where(line => !string.IsNullOrEmpty(line)).Select(line => line.Trim().TrimStart('?').Split('\t')).Where(data => data.Length > 10))) { yield return(new Skill(data, SkillNames.ContainsKey(data[62]) ? SkillNames[data[62]] : "")); } }