I am developing a WPF application that uses Google FireStore as Cloud Storage. I have added a somekey.json in my project in order to establish connection. When I Run application the file get exported to the bin folder. Is there any other way to connect to FireStore without the file? Like using in Code Credentials.
Asked
Active
Viewed 127 times
0
-
Which keys are you referring to. Are you talking about the config values? – Hydra Sep 15 '21 at 23:04
-
If you are talking about the `google-services.json` file that you download from the Firebase console, you'll want to have a look here: https://stackoverflow.com/questions/37482366/is-it-safe-to-expose-firebase-apikey-to-the-public – Frank van Puffelen Sep 15 '21 at 23:12
-
@FrankvanPuffelen Everyone there is saying that I should use rules there. Actually the Firestore rules are not working. even on Blocked mode, data is still accessible – Shazaib Sep 16 '21 at 00:29
-
I was mostly trying to clarify what you mean by `somekey.json`. If that is `google-services.json`, my answer I linked explains why that is not a security risk. If you can access the database even with `false` rules, that might mean you're using mechanism that provides administrative credentials. – Frank van Puffelen Sep 16 '21 at 01:25
1 Answers
0
YES YOU CAN DO IT WITH MD5 Encryption save MD5 AS STRING IN YOUR APPLICATION CREATE STRINGS AND FIRESTORE VERIABEL
string projectId;
FirestoreDb fireStoreDb;
string googleJs;
private void wirteAuthFile() {
string hash = "fts";
string auth = "CCfjJhf9p/4prFI4e3RIk6v0S3QXbTcO1CQP66Kk=";
File.WriteAllText("SOFTWAREAUTH.dll", auth);
using (StreamReader readtext = new StreamReader("SOFTWAREAUTH.dll"))
{string readText = readtext.ReadLine();
googleJs = (Decrypition(readText));}
File.WriteAllText("SOFTWAREAUTH.dll", googleJs);
ConnectFirestore();
}
private static string Decrypition(string text)
{
string hash = "fts";
byte[] data = Convert.FromBase64String(text);
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
{
byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
using (TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider() { Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 })
{
ICryptoTransform transform = tripleDES.CreateDecryptor();
byte[] results = transform.TransformFinalBlock(data, 0, data.Length);
return UTF8Encoding.UTF8.GetString(results);
}
}
}
HERE YOU CAN CONNECT WITH FIRESTORE
private void ConnectFirestore() {
string filepath = "SOFTWAREAUTH.dll";
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", filepath);
projectId = "shopshopf";
fireStoreDb = FirestoreDb.Create(projectId);
File.Delete(filepath);
}

Pridesoft ITsolutions
- 1
- 1
- 1
-
1Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 31 '23 at 22:04