Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   c a delphi7 (https://www.clubdelphi.com/foros/showthread.php?t=95984)

DarkSton 29-11-2022 19:32:00

c a delphi7
 
hola comunidad encontre este codigo AES
Código PHP:

private static byte[] AesEncryptBlock(byte[] plainTextbyte[] Key)
        {
            
byte[] output_buffer = new byte[plainText.Length];

            
using (AesManaged aesAlg = new AesManaged())
            {
                
aesAlg.Mode CipherMode.ECB;

                
aesAlg.BlockSize 128;
                
aesAlg.KeySize 128;
                
aesAlg.Padding PaddingMode.None;
                
aesAlg.Key Key;

                
// Create a encryptor to perform the stream transform.
                
ICryptoTransform encryptor aesAlg.CreateEncryptor(aesAlg.KeyaesAlg.IV);
                
encryptor.TransformBlock(plainText0plainText.Lengthoutput_buffer0);
            }

            return 
output_buffer;
        }

        
// not used, but nice to have around
        
private static byte[] AesDecryptBlock(byte[] cipherTextbyte[] Key)
        {
            
byte[] output_buffer = new byte[cipherText.Length];

            
using (AesManaged aesAlg = new AesManaged())
            {
                
aesAlg.Mode CipherMode.ECB;

                
aesAlg.BlockSize 128;
                
aesAlg.KeySize 128;
                
aesAlg.Padding PaddingMode.None;
                
aesAlg.Key Key;

                
// Create a decryptor to perform the stream transform.
                
ICryptoTransform decryptor aesAlg.CreateDecryptor(aesAlg.KeyaesAlg.IV);
                
decryptor.TransformBlock(cipherText0cipherText.Lengthoutput_buffer0);
            }
            return 
output_buffer;
        }

        static 
string GLParameters(string usernamestring password)
        {
            
// final block (unknown) looks like 4 DWORDs, first one being always zero, second always nonzero, third and fourth are occasionally zero
            
List<byteresult = new List<byte>();
            
byte[] key = { 0xFA0xEE0x850xF20x400x730xD90x160x130x900x190x7F0x6E0x560x2A0x67 };
            
byte[] finalBlock = { 000000000000000};
            
result.AddRange(AesEncryptBlock(StringToBytes(username16), key));
            
result.AddRange(AesEncryptBlock(StringToBytes(password16), key));
            
result.AddRange(AesEncryptBlock(finalBlockkey));
            return 
BitConverter.ToString(result.ToArray()).Replace("-""").ToUpper();
        } 

como puedo pasarlo a delphi7

cloayza 29-11-2022 21:25:39

Un gran maestro del Club Seaone, publico hace tiempo creo recordar funciones para lo que requieres...

Mira en su web http://delphi.jmrds.com/

SeCrypt (Colección de funciones criptográficas)

Saludos cordiales

escafandra 30-11-2022 07:33:36

El fragmento de código no es C. Tampoco lo puedes traducir porque se basa en la clase AesManaged cuyo código no aparece ni comentas que esté importado desde una librería.

Mira el código de [seoane].

Saludos.


La franja horaria es GMT +2. Ahora son las 16:31:49.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi