Beispiel #1
0
        public static string EncryptedSHA(string inputDir)
        {
            string inputFile = inputDir.Split('\\').Last();
            string hashFile  = SHA512File(inputFile);
            string encSHA    = EncryptionAsym.RSAFile(hashFile, true, Constants.privKljuc, false, false);

            return(encSHA);
        }
Beispiel #2
0
        public static string DecryptedSHA(string inputDir)
        {
            string inputFile = inputDir.Split('\\').Last();
            string hashFile  = inputFile + Constants.hashExtension;

            Console.WriteLine(Constants.RSAEnc + hashFile);
            string decSHA = EncryptionAsym.RSAFile(Constants.RSADec + hashFile, true, Constants.javKljuc, true, false);

            return(decSHA);
        }
Beispiel #3
0
 private void btnEncryptSymmetricalKey_Click(object sender, EventArgs e)
 {
     try
     {
         string name = openFileDialog1.FileName.Split('\\').Last();
         //if (openFileDialog1.)
         name = EncryptionAsym.RSAFile(name, true, Constants.javKljuc, true, false);
         MessageBox.Show("Generirana datoteka " + name);
     }
     catch (FileNotFoundException ex)
     {
         MessageBox.Show(ex.Message);
     }catch (KriviUnosException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #4
0
 private void btnDecryptSymmetricalKey_Click(object sender, EventArgs e)
 {
     try
     {
         string name    = openFileDialog1.FileName.Split('\\').Last();
         bool   isAscii = checkIsAscii.Checked;
         name = EncryptionAsym.RSAFile(name, true, Constants.privKljuc, false, isAscii);
         MessageBox.Show("Generirana datoteka " + name);
     }
     catch (FileNotFoundException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (KriviUnosException)
     {
         MessageBox.Show("Datoteka nije RSA enkriptirana");
     }
 }
Beispiel #5
0
        public static bool CheckSignature(string name)
        {
            string fileName = name.Split('\\').Last();

            if (!fileName.Contains(Constants.sigExt))
            {
                throw new KriviUnosException("Potrebno je označiti datoteku potpisa");
            }
            string file     = fileName.Remove(fileName.LastIndexOf(Constants.sigExt));
            string fileText = Utilities.readFile(file);
            string hashCalc = Convert.ToBase64String(Hashing.SHA512String(fileText));

            string hashDec = EncryptionAsym.RSAFile(fileName, false, "javniKljuc.txt", true, false);

            byte[] hashDecBin = Convert.FromBase64String(hashDec);
            hashDecBin = hashDecBin.Skip(Constants.RSAKeySize / 8 - Constants.hashSize / 8).ToArray();
            hashDec    = Convert.ToBase64String(hashDecBin);

            return(hashDec == hashCalc);
        }