public DecryptKeyStoreFromJson ( string password, string json ) : byte[] | ||
password | string | |
json | string | |
return | byte[] |
void LoadOrCreateAccount() { Nethereum.Signer.EthECKey key; var password = account_.password_; if (string.IsNullOrEmpty(keyStore_)) { if (encrypted_ && string.IsNullOrEmpty(password)) { Thread.MemoryBarrier(); result_ = -1; return; } key = CreateAccount(password, encrypted_, out keyStore_); } else { //generate ecKey from encrypted key store if (encrypted_) { var service = new Nethereum.KeyStore.KeyStoreService(); key = new Nethereum.Signer.EthECKey( service.DecryptKeyStoreFromJson(password, keyStore_), true); } else { key = new Nethereum.Signer.EthECKey(keyStore_); } } account_.key_ = key; Thread.MemoryBarrier(); result_ = 1; }
public static string GetPrivateKeyByKeystoreAndPassword(string keystore, string password) { var keystoreservice = new Nethereum.KeyStore.KeyStoreService(); var privateKey = keystoreservice.DecryptKeyStoreFromJson(password, keystore); return(privateKey.ToHex()); }
public Account LoadFromKeyStoreFile(string filePath, string password) { var keyStoreService = new Nethereum.KeyStore.KeyStoreService(); using (var file = File.OpenText(filePath)) { var json = file.ReadToEnd(); var key = keyStoreService.DecryptKeyStoreFromJson(password, json); return(new Account(key)); } }
public void ImportAccountFromJson(string password, string encryptedJson) { var keystoreservice = new Nethereum.KeyStore.KeyStoreService(); var privateKey = keystoreservice.DecryptKeyStoreFromJson(password, encryptedJson); var address = keystoreservice.GetAddressFromKeyStore(encryptedJson); this.password = password; this.publicAddress = address; this.privateKey = ConvertKey(privateKey); this.encryptedJson = encryptedJson; }
private void LoadWalletFromKeystore(string keystoreJson, string password) { if (string.IsNullOrEmpty(keystoreJson) || string.IsNullOrEmpty(password)) { throw new System.InvalidOperationException("keystoreJson or password is null or empty"); } var keystoreservice = new Nethereum.KeyStore.KeyStoreService(); var privateKey = keystoreservice.DecryptKeyStoreFromJson(password, keystoreJson); var ecKey = new EthECKey(privateKey, true); var address = ecKey.GetPublicAddress(); PrivateKeyBytes = privateKey; PrivateKeyString = privateKey.ToHex(); PublicAddress = address; }
public void LoadAccount() { var encryptedJson = PlayerPrefs.GetString("encryptedJson"); Debug.Log("encryptedJson " + encryptedJson); var password = "******"; var keystoreservice = new Nethereum.KeyStore.KeyStoreService(); var privateKey = keystoreservice.DecryptKeyStoreFromJson(password, encryptedJson); var ecKey = new EthECKey(privateKey, true); var address = ecKey.GetPublicAddress(); Debug.Log("address: " + address + "\n privateKey: " + privateKey.ToString()); accountAddress = address; accountPrivateKey = privateKey.ToHex(); Debug.Log("accountAddress: " + accountAddress + "\n accountPrivateKey: " + accountPrivateKey); }
public void ImportAccountFromJson(string password, string encryptedJson) { try { var keystoreservice = new Nethereum.KeyStore.KeyStoreService(); var privateKey = keystoreservice.DecryptKeyStoreFromJson(password, encryptedJson); var address = keystoreservice.GetAddressFromKeyStore(encryptedJson); this.password = password; this.publicAddress = address; this.privateKey = ConvertKey(privateKey); this.encryptedJson = encryptedJson; } catch (DecryptionException ex) { Debug.Log("DecryptionException"); FindObjectOfType <AccountManager>().passwordNotice.enabled = true; return; } }