Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Source array was not long enough.

[es] :: .NET :: .NET Desktop razvoj :: Source array was not long enough.

[ Pregleda: 1981 | Odgovora: 6 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

theilusion

Član broj: 331616
Poruke: 44
31.223.144.*



+1 Profil

icon Source array was not long enough.26.01.2016. u 22:15 - pre 48 meseci
Pozdrav svima.
Na slici je printscreen jedne metode na koju dobijam exception.
http://picpaste.com/Screenshot_7-dFA8Vq9P.png

Sta sa nizom nije dovoljno "long"?

Pozzzz
 
Odgovor na temu

dusans
Stojanov Dušan
Pančevo

Član broj: 9551
Poruke: 1324
*.dynamic.sbb.rs.



+306 Profil

icon Re: Source array was not long enough.26.01.2016. u 22:34 - pre 48 meseci
Kada konvertuješ Settings.Serial u ASCII niz bajtova, dobijaš niz duži od 16 elemenata.
Rešenje - ili skrati vrednost Settings.Serial ili proširi byteSerial.
 
Odgovor na temu

theilusion

Član broj: 331616
Poruke: 44
31.223.144.*



+1 Profil

icon Re: Source array was not long enough.26.01.2016. u 22:57 - pre 48 meseci
Code:

public static CryptoStream GetCryptoReadStream( Stream stream ) 
        {
            ICryptoTransform encryptor;
            Byte[] byteName;
            Byte[] byteSerial;

            byteName=new Byte[32];
            byteName.Initialize();

            byteSerial=new Byte[16];
            byteSerial.Initialize();

            Array.Copy(Encoding.ASCII.GetBytes(Settings.Name),0,byteName,0,
                Math.Min(Encoding.ASCII.GetBytes(Settings.Name).Length,32));
            Array.Copy(Encoding.ASCII.GetBytes(Settings.Serial),0,byteSerial,0,16);

            RijndaelManaged rm;
            rm=new RijndaelManaged();

            encryptor=rm.CreateDecryptor(byteName,byteSerial);

            CryptoStream cryptoStream;
            cryptoStream=new CryptoStream(stream,encryptor,CryptoStreamMode.Read);

            return cryptoStream;
        }


Code:
byteSerial = new Byte[32];


Je li dovoljno ovde reći da je byteSerial sada dužine 32?

Hvala puno na savetu.
 
Odgovor na temu

theilusion

Član broj: 331616
Poruke: 44
31.223.144.*



+1 Profil

icon Re: Source array was not long enough.27.01.2016. u 15:59 - pre 48 meseci
Ovo sto sam sam sebi predložio ne radi. Tj opet exception
 
Odgovor na temu

dusans
Stojanov Dušan
Pančevo

Član broj: 9551
Poruke: 1324
*.dynamic.sbb.rs.



+306 Profil

icon Re: Source array was not long enough.27.01.2016. u 16:05 - pre 48 meseci
Code:

Array.Copy(Encoding.ASCII.GetBytes(Settings.Serial),0,byteSerial,0,
     Math.Min(Encoding.ASCII.GetBytes(Settings.Serial).Length,16));
 
Odgovor na temu

theilusion

Član broj: 331616
Poruke: 44
31.223.144.*



+1 Profil

icon Re: Source array was not long enough.27.01.2016. u 18:47 - pre 48 meseci
Izvini ako sam te razumeo. Kazes ovo:

Code:

Array.Copy(Encoding.ASCII.GetBytes(Settings.Name),0,byteName,0,
                Math.Min(Encoding.ASCII.GetBytes(Settings.Name).Length,32));

            Array.Copy(Encoding.ASCII.GetBytes(Settings.Serial),0,byteSerial,0,16);



da napisem ovako:

Code:

Array.Copy(Encoding.ASCII.GetBytes(Settings.Serial),0,byteSerial,0,
     Math.Min(Encoding.ASCII.GetBytes(Settings.Serial).Length,16));

 Array.Copy(Encoding.ASCII.GetBytes(Settings.Serial),0,byteSerial,0,16);


Ne razumem bas ovo :(
 
Odgovor na temu

theilusion

Član broj: 331616
Poruke: 44
31.223.144.*



+1 Profil

icon Re: Source array was not long enough.28.01.2016. u 21:40 - pre 48 meseci
Džaba, probao sam i ovo prethodno i menjao dužinu niza byteSerial uvek ista greška.
 
Odgovor na temu

[es] :: .NET :: .NET Desktop razvoj :: Source array was not long enough.

[ Pregleda: 1981 | Odgovora: 6 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.