public void SetRandomSeed() { InteractablePathManager.SetRandomSeed(); BIP39Converter bpc = new BIP39Converter(); TMP_InputField seedInputField = GetComponentInChildren <TMP_InputField>(); seedInputField.text = InteractablePathManager.SeedString; }
public void SetRandomBIP39Seed() { BIP39Converter bpc = new BIP39Converter(); InteractablePathManager.SetRandomSeed(); TMP_InputField seedInputField = GetComponentInChildren <TMP_InputField>(); seedInputField.text = bpc.getSentenceFromHex(InteractablePathManager.SeedString); }
public void SetupEncodeSeedBip() { SetLevelPanelDefault(); if (GameManager.Mode == GameMode.Rehearsal) { TMP_InputField seedInputField = GetComponentInChildren <TMP_InputField>(true); string seedFromInput = seedInputField.text; string hexSeed = ""; if (!detectHex(seedFromInput) && validBip(seedFromInput)) { BIP39Converter bpc = new BIP39Converter(); hexSeed = bpc.getHexFromSentence(seedFromInput); } else { hexSeed = seedFromInput; if (InteractableConfig.SeedHexLength % 2 == 1) { if (seedFromInput.Length == InteractableConfig.SeedHexLength) { string seedText = seedFromInput + "0"; char[] array = seedText.ToCharArray(); array[array.Length - 1] = array[array.Length - 2]; array[array.Length - 2] = '0'; hexSeed = new string(array); } else if (seedFromInput.Length == InteractableConfig.SeedHexLength + 1) { char[] array = seedFromInput.ToCharArray(); array[array.Length - 2] = '0'; hexSeed = new string(array); } else { Debug.Log("Seed: " + hexSeed); } } } //Debug.Log("Sentence: " + seedFromInput); Debug.Log("Seed: " + hexSeed); InteractablePathManager.SeedString = hexSeed; int[] siteIDs = InteractablePathManager.GetPathSiteIDs(); SetIconAndPanelForRehearsal(siteIDs); } }
public void copyHexSeed() { var textList = Instance.GetComponentsInChildren <TMPro.TextMeshProUGUI>(); BIP39Converter bpc = new BIP39Converter(); string seed = bpc.getHexFromSentence(textList[0].text); #if UNITY_WEBGL Copy(seed); #else GUIUtility.systemCopyBuffer = seed; #endif textList[1].text = "Seed Copied"; textList[1].gameObject.SetActive(true); }
public void SwitchSeedFormat() { TMP_InputField seedInputField = GetComponentInChildren <TMP_InputField>(); if (isBip) { seedInputField.text = InteractablePathManager.SeedString; isBip = false; } else { BIP39Converter bpc = new BIP39Converter(); seedInputField.text = bpc.getSentenceFromHex(InteractablePathManager.SeedString); isBip = true; } }
public void downloadSeed() { var textList = Instance.GetComponentsInChildren <TMPro.TextMeshProUGUI>(); BIP39Converter bpc = new BIP39Converter(); string seed = bipSeed + "\n0x" + hexSeed; //QRCodeGenerator qrGenerator = new QRCodeGenerator(); //QRCodeData qrCodeData = qrGenerator.CreateQrCode(textList[0].text, QRCodeGenerator.ECCLevel.Q); //UnityQRCode qrCode = new UnityQRCode(qrCodeData); //Texture2D qrCodeAsTexture2D = qrCode.GetGraphic(20); //byte[] bytes = qrCodeAsTexture2D.EncodeToPNG(); //File.WriteAllBytes(Application.dataPath + "/../SavedQRCode.png", bytes); #if UNITY_WEBGL Download("seed.txt", seed); #elif UNITY_EDITOR string path = EditorUtility.SaveFilePanel("Save As", "Downloads", "seed", "txt"); if (path.Length != 0) { using (StreamWriter outputFile = new StreamWriter(path)) { outputFile.WriteLine(seed); } } #else string downloads = ""; if (System.Environment.OSVersion.Platform == System.PlatformID.Unix) { string home = System.Environment.GetEnvironmentVariable("HOME"); downloads = System.IO.Path.Combine(home, "Downloads"); } else { downloads = System.Convert.ToString(Microsoft.Win32.Registry.GetValue( @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" , "{374DE290-123F-4565-9164-39C4925E467B}" , String.Empty)); } using (StreamWriter outputFile = new StreamWriter(Path.Combine(downloads, "seed.txt"))) { outputFile.WriteLine(seed); } #endif //textList[1].text = "Seed Downloaded"; //textList[1].gameObject.SetActive(true); }
// Checks a string to see if it's a valid bip-39 seed phrase public static bool validBip(string seed) { BIP39Converter bpc = new BIP39Converter(); string hex = ""; try { hex = bpc.getHexFromSentence(seed); } catch (Exception e) { Debug.Log("Exception: " + e); return(false); } return(true); }
public void downloadSeed() { var textList = Instance.GetComponentsInChildren <TMPro.TextMeshProUGUI>(); BIP39Converter bpc = new BIP39Converter(); string seed = bipSeed + "\n0x" + hexSeed; #if UNITY_WEBGL Download("seed.txt", seed); #elif UNITY_EDITOR string path = EditorUtility.SaveFilePanel("Save As", "Downloads", "seed", "txt"); if (path.Length != 0) { using (StreamWriter outputFile = new StreamWriter(path)) { outputFile.WriteLine(seed); } } #else string downloads = ""; if (System.Environment.OSVersion.Platform == System.PlatformID.Unix) { string home = System.Environment.GetEnvironmentVariable("HOME"); downloads = System.IO.Path.Combine(home, "Downloads"); } else { downloads = System.Convert.ToString(Microsoft.Win32.Registry.GetValue( @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" , "{374DE290-123F-4565-9164-39C4925E467B}" , String.Empty)); } using (StreamWriter outputFile = new StreamWriter(Path.Combine(downloads, "seed.txt"))) { outputFile.WriteLine(seed); } #endif //textList[1].text = "Seed Downloaded"; //textList[1].gameObject.SetActive(true); }
/// <summary> Toggles On the EndGameUI </summary> static public void ToggleOn() { if (Instance.gameObject.activeSelf) { return; } Instance.gameObject.SetActive(true); var textList = Instance.GetComponentsInChildren <TMPro.TextMeshProUGUI>(); SeedConverter converter = new SeedConverter(); BIP39Converter bpc = new BIP39Converter(); //textList[0].text = converter.DecodeSeed(); /* for (int i = 0; i < textList.Length; i++) * { * Debug.Log("Text data #" + i + ": " + textList[i].text); * } */ if (InteractableConfig.SeedHexLength % 2 == 1) { string alteredSeedText = converter.DecodeSeed(); string sentence = bpc.getSentenceFromHex(alteredSeedText); char[] array = alteredSeedText.ToCharArray(); array[array.Length - 2] = array[array.Length - 1]; alteredSeedText = new string(array); if (alteredSeedText.Length > 1) { alteredSeedText = alteredSeedText.Substring(0, (alteredSeedText.Length - 1)); } hexSeed = alteredSeedText; bipSeed = sentence; textList[0].text = sentence; } else { //textList[0].text = converter.DecodeSeed(); string hex = converter.DecodeSeed(); string sentence = bpc.getSentenceFromHex(hex); hexSeed = hex; bipSeed = sentence; textList[0].text = sentence; } //Debug.Log("Hex: " + hexSeed); //Debug.Log("Bip: " + bipSeed); if (GameManager.Mode == GameMode.Rehearsal) { //textList[2].text = "Key Learned!"; textList[3].text = "Practice Again"; } else { //textList[2].text = "Key Recovered!"; textList[3].text = "Try Again"; } for (int i = 0; i < textList.Length; i++) { //Debug.Log("Text data #" + i + ": " + textList[i].text); } setupCharacterMode(); }