[ theilusion @ 26.01.2016. 22:15 ] @
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 |
[ theilusion @ 26.01.2016. 22:15 ] @
[ dusans @ 26.01.2016. 22:34 ] @
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. [ theilusion @ 26.01.2016. 22:57 ] @
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. [ theilusion @ 27.01.2016. 15:59 ] @
Ovo sto sam sam sebi predložio ne radi. Tj opet exception
[ dusans @ 27.01.2016. 16:05 ] @
Code: Array.Copy(Encoding.ASCII.GetBytes(Settings.Serial),0,byteSerial,0, Math.Min(Encoding.ASCII.GetBytes(Settings.Serial).Length,16)); [ theilusion @ 27.01.2016. 18:47 ] @
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 :( [ theilusion @ 28.01.2016. 21:40 ] @
Džaba, probao sam i ovo prethodno i menjao dužinu niza byteSerial uvek ista greška.
Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|