public static void WriteObjectToBlob(PassObject _objectToBlob, string _saveAsUniqueId, string _fileDir) { MemoryStream memorystream = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(memorystream, _objectToBlob); byte[] BlobData = memorystream.ToArray(); WriteBin(BlobData, _saveAsUniqueId, _fileDir); }
public static PassObject ReadBlobToObject(string _readAsUniqueId, string _fileDir) { //Read from bin string filePath = _fileDir + CandyStore.GetParameters().FileFolder + _readAsUniqueId + ".bin"; if (!File.Exists(filePath)) { throw new Exception("Filepath does not exist"); } byte[] BlobData = ReadBin(filePath); MemoryStream memorystreamd = new MemoryStream(BlobData); BinaryFormatter bfd = new BinaryFormatter(); PassObject deserializedobject = bfd.Deserialize(memorystreamd) as PassObject; memorystreamd.Close(); return(deserializedobject); }
public static Boolean CreatePass(string _websiteString, string _websitePass, string _encryptionKey, string _fileDir, int _numOfIterations) { string uniqueId = CandyStore.PBKDF2Service(_websiteString, _numOfIterations); uniqueId = CandyStore.ToHexString(uniqueId); string encryptedPass = EncryptDecryptStore.Encrypt(_websitePass, _encryptionKey); PassObject passObject = new PassObject(); //Create new instance of PassObject try { passObject.SetUniqueId(uniqueId); passObject.SetEncryptedPass(encryptedPass); StorageHelper.WriteObjectToBlob(passObject, uniqueId, _fileDir); //Store object return(true); } catch { return(false); } }