NetTalk Central

Author Topic: Decrypt with clarion  (Read 2807 times)

osquiabro

  • Hero Member
  • *****
  • Posts: 685
    • View Profile
    • Email
Decrypt with clarion
« on: August 02, 2024, 05:40:22 AM »
Is it possible to decrypt a value with Clarion, perhaps with Cryptonite, from an Encrypt in C#? I have a source code in C# with a password. I have tried it with Cryptonite but without result.

i know the value of one field that is omar11 and the encriptation is 2boh1Rk2ze3J8grK7pAiQQ==

the source decrypt correctly the value, but i need decrypt with clarion. Everythig is in the code

this is the source code that can run in this site https://www.jdoodle.com/

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;

using System;

class Program
{
    static void Main() {
        string result;
        // Create an instance of the Cryptography class using the constructor that takes a SymmetricAlgorithm parameter
        Cryptography cryptography = new Cryptography(new RijndaelManaged());
        result = cryptography.Decrypt("2boh1Rk2ze3J8grK7pAiQQ==");
        Console.Write("La Contrase?a desencriptada es: " + result);
    }
}

public class Cryptography
{
    //================================================
    // Fields
    //================================================
    private string Key;
    private SymmetricAlgorithm mobjCryptoService;

    //================================================
    // Methods
    //================================================
    public Cryptography(SymmetricAlgorithm ServiceProvider)
    {
        this.Key = "malla@malla.com";
        this.mobjCryptoService = ServiceProvider;
    }

    public string Decrypt(string Source)
    {
        byte[] buffer = Convert.FromBase64String(Source);
        MemoryStream stream = new MemoryStream();
        byte[] legalKey = this.GetLegalKey(this.Key);
        this.mobjCryptoService.Key = legalKey;
        this.mobjCryptoService.IV = legalKey;
        ICryptoTransform transform = this.mobjCryptoService.CreateDecryptor();
        CryptoStream stream2 = new CryptoStream(stream,  transform,  CryptoStreamMode.Write);
        stream2.Write(buffer,  0,  buffer.Length);
        stream2.FlushFinalBlock();
        byte[] bytes = stream.ToArray();
        stream.Close();
        stream = null;
        stream2.Close();
        stream2 = null;
        return Encoding.UTF8.GetString(bytes);
    }

    public string Encrypt(string Source)
    {
        byte[] bytes = Encoding.ASCII.GetBytes(Source);
        MemoryStream stream = new MemoryStream();
        byte[] legalKey = this.GetLegalKey(this.Key);
        this.mobjCryptoService.Key = legalKey;
        this.mobjCryptoService.IV = legalKey;
        ICryptoTransform transform = this.mobjCryptoService.CreateEncryptor();
        CryptoStream stream2 = new CryptoStream(stream,  transform,  CryptoStreamMode.Write);
        stream2.Write(bytes,  0,  bytes.Length);
        stream2.FlushFinalBlock();
        byte[] inArray = stream.ToArray();
        stream.Close();
        stream = null;
        stream2.Close();
        stream2 = null;
        return Convert.ToBase64String(inArray);
    }

    private byte[] GetLegalKey(string Key)
    {
        string s = "";
        char paddingChar = char.Parse(" ");
        if (this.mobjCryptoService.LegalKeySizes.Length > 0)
        {
            int minSize = this.mobjCryptoService.LegalKeySizes[0].MinSize;
            while ((Key.Length * 8) > minSize)
            {
                minSize += this.mobjCryptoService.LegalKeySizes[0].SkipSize;
            }
            s = Key.PadRight(minSize / 8,  paddingChar);
        }
        else
        {
            s = Key;
        }
        return Encoding.ASCII.GetBytes(s);
    }

    //================================================
    // Properties
    //================================================
    public string SetKey
    {
        get
        {
            return this.Key;
        }
        set
        {
            this.Key = value;
        }
    }

    //================================================
    // Nested Types
    //================================================
    public enum SymmProvEnum
    {
        DES,
        RC2,
        Rijndael
    }
}