Exemplo n.º 1
0
 public static byte[] EncryptReport(Report r, string publicKey)
 {
     // Report r = Report.CreateTextReport(reportTitle, reportText);
     byte[] reportData          = Report.SerializeReport(r);
     byte[] encryptedReportData = Cryptographics.Encrypt(reportData, publicKey);
     byte[] signed = Cryptographics.HashSign(encryptedReportData, publicKey);
     return(signed);
 }
Exemplo n.º 2
0
        public bool VerifyUser(string username, string password, out object userData)
        {
            //Normally database lookup for comparing
            if ((username.ToLower() == "admin" && Cryptographics.Hash(password, HashType.Sha256) == ImaginaryAdminPass) || ImaginaryOtherUsers.Contains(username.ToLower()))
            {
                if (username.ToLower() == "admin")
                {
                    userData = ImaginaryAdminID;
                }
                else
                {
                    userData = Guid.NewGuid().ToString();
                }
                return(true);
            }

            userData = null;
            return(false);
        }
Exemplo n.º 3
0
 public static Report DecryptReport(byte[] reportData, string privateKey)
 {
     byte[] data = Cryptographics.HashVerify(reportData, privateKey);
     data = Cryptographics.Decrypt(data, privateKey);
     return(Report.DeserializeReport(data));
 }