Ejemplo n.º 1
0
 public string EncryptWithSessionB64(string text)
 {
     byte[] IV         = m_sessionIV;
     byte[] encMessage = SCSC_AES.Encrypt(text, m_sessionPassword, ref IV);
     byte[] im         = new byte[IV.Length + encMessage.Length];
     //Copy from IV to output, IV size bytes (must be 32)
     Array.Copy(IV, im, IV.Length);
     Array.Copy(encMessage, 0, im, IV.Length, encMessage.Length);
     return(Convert.ToBase64String(im));
 }
Ejemplo n.º 2
0
 public string DecryptWithSessionB64(string encryptedB64)
 {
     byte[] encrypted     = Convert.FromBase64String(encryptedB64);
     byte[] IV            = m_sessionIV;
     byte[] encryptedWOIV = new byte[encrypted.Length - 16];
     //Copy from encrypted to IV, IV size bytes (must be 32)
     Array.Copy(encrypted, IV, 16);
     //Copy from encrypted to encryptedWOIV[32], encrypted size bytes - IV size bytes (must be 32)
     Array.Copy(encrypted, 16, encryptedWOIV, 0, encrypted.Length - 16);
     return(SCSC_AES.Decrypt(encryptedWOIV, m_sessionPassword, IV));
 }
Ejemplo n.º 3
0
 public static string GetAESKeyB64(string password = "")
 {
     if (String.IsNullOrEmpty(password))
     {
         return(Convert.ToBase64String(SCSC_AES.GetSessionKey()));
     }
     else
     {
         return(Convert.ToBase64String(sha256_hash(password)));
     }
 }
Ejemplo n.º 4
0
 //AES256 with key from SHA256 of user's password used for encrypt/decrypt user data
 public string DecryptUserDataB64(string encryptedB64)
 {
     byte[] encrypted = Convert.FromBase64String(encryptedB64);
     return(SCSC_AES.Decrypt(encrypted, m_shaPassword, m_shaUser));
 }
Ejemplo n.º 5
0
 //AES256 with key from SHA256 of user's password used for encrypt/decrypt user data
 public string EncryptUserDataB64(string text)
 {
     return(Convert.ToBase64String(SCSC_AES.Encrypt(text, m_shaPassword, ref m_shaUser)));
 }