public bool Login(LoginRequest _loginRequest) { WalletData ret = null; if (_loginRequest.CreateNewWallet && _loginRequest.PassCode != "" && _loginRequest.WalletName != "" && !FileBinIO.Exists(_loginRequest.WalletName)) { ret = GenerateWallet(_loginRequest.PassCode, _loginRequest.WalletName); } else if (_loginRequest.CreateNewWallet) { Console.WriteLine("Missing wallet name or password, or password requirements do not match, or wallet already exists"); return(false); //Todo: add exception error } else { ret = LoginWallet(_loginRequest); } Data = ret; return(Data == null ? false : true); }
public static void WriteWalletData(WalletData _WalletDataToBlob, string _walletName) { //TODO: Move serialization to FileBinIO to avoid duplicating code on multiple objects MemoryStream memorystream = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(memorystream, _WalletDataToBlob); byte[] BlobData = memorystream.ToArray(); FileBinIO.WriteBin(BlobData, _walletName); }
public static WalletData ReadBlobToWalletData(string _walletName) { //Read from bin //TODO: Move deserialization to FileBinIO to avoid duplicating code on multiple objects byte[] BlobData = FileBinIO.ReadBin(_walletName); MemoryStream memorystreamd = new MemoryStream(BlobData); BinaryFormatter bfd = new BinaryFormatter(); WalletData deserializedBlock = bfd.Deserialize(memorystreamd) as WalletData; memorystreamd.Close(); return(deserializedBlock); }