/** * Data re-Encryption with Master Password * The Master Password is used as a parameter to Encrypt/Decrypt data * Hence every time a new Master Password is set, all data must first be decrypted using old Password before being encrypted using new one */ private void ReEncryptData(string OldPassword) { Crytography Crypto = new Crytography(); for (int i = 0; i < NumberOfPasswords(); i++) { string PasswordData = PlayerPrefs.GetString(i.ToString()); PasswordData = Crypto.Decrypt(PasswordData, i.ToString(), OldPassword); PlayerPrefs.SetString(i.ToString(), Crypto.Encrypt(PasswordData, i.ToString())); } }
/** * Get Password and related Information */ public PasswordInfo GetPasswordInfo(string PwID) { PasswordInfo PwInfo = new PasswordInfo(); Crytography Decryptor = new Crytography(); string EncrytedData; string PlainJson; EncrytedData = PlayerPrefs.GetString(PwID); PlainJson = Decryptor.Decrypt(EncrytedData, PwID); PwInfo = PwInfo.CreateFromJSON(PlainJson); return(PwInfo); }
/** * Save Password and related Information */ public void SavePasswordInfo(string PwID, string Title, string User, string PwValue, string ModDate) { PasswordInfo PwInfo = new PasswordInfo(); Crytography Encryptor = new Crytography(); string PasswordJson; string EncryptedData; PwInfo.PasswordTitle = Title; PwInfo.UserID = User; PwInfo.PasswordValue = PwValue; PwInfo.ModifiedDate = ModDate; PasswordJson = PwInfo.SaveToJson(); EncryptedData = Encryptor.Encrypt(PasswordJson, PwID); PlayerPrefs.SetString(PwID, EncryptedData); }