Esempio n. 1
0
        public string HashFile(string path)
        {
            sha512 = new SHA512Managed();
            calculatedHash = null;
            hashString = null;
            FileInfo fi = new FileInfo(path);

            try
            {
                FileStream fs = System.IO.File.OpenRead(path);
                fs.Position = 0;
                calculatedHash = sha512.ComputeHash(fs);
                fs.Close();
                hashString = ByteToString(calculatedHash);
                return hashString;
            }
            catch (FileNotFoundException)
            {
                // file not found
                Logger.Write("Error, file not found");
            }
            catch (IOException)
            {
                // file could not be accessed
                // warn user and try again on OK
                Logger.Write("Error, file not accessible " + fi.Name);
            }
            catch (UnauthorizedAccessException)
            {
                // no access permission
            }
            return null;
        }
Esempio n. 2
0
        /// <summary>
        /// Open file and get it's SHA1 hash
        /// </summary>
        /// <param name="file_name">File name (full path)</param>
        /// <returns>String representation of the SHA1 hash</returns>
        public static string GetSHAHashFromFile(string file_name, SHAType shaType)
        {
            System.IO.FileStream file = new System.IO.FileStream(file_name, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            byte[] retVal             = null;
            switch (shaType)
            {
            case SHAType.SHA1:
                System.Security.Cryptography.SHA1 sha1obj = new System.Security.Cryptography.SHA1CryptoServiceProvider();
                retVal = sha1obj.ComputeHash(file);
                break;

            case SHAType.SHA256:
                System.Security.Cryptography.SHA256 sha256 = System.Security.Cryptography.SHA256.Create();
                retVal = sha256.ComputeHash(file);
                break;

            case SHAType.SHA384:
                System.Security.Cryptography.SHA384 sha384 = System.Security.Cryptography.SHA384.Create();
                retVal = sha384.ComputeHash(file);
                break;

            case SHAType.SHA512:
                System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create();
                retVal = sha512.ComputeHash(file);
                break;
            }
            file.Close();
            return(BitConverter.ToString(retVal).Replace("-", "").ToLower());
        }
 public static string GetSHA512(this Stream s)
 {
     using (System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create())
     {
         return(Convert.ToHexString(sha512.ComputeHash(s)).ToLower());
     }
 }
Esempio n. 4
0
        internal static async Task InstallFromStream(Stream stream, Library library, string packagesDirectory,
            SHA512 sha512)
        {
            var packagePathResolver = new DefaultPackagePathResolver(packagesDirectory);

            var targetPath = packagePathResolver.GetInstallPath(library.Name, library.Version);
            var targetNuspec = packagePathResolver.GetManifestFilePath(library.Name, library.Version);
            var targetNupkg = packagePathResolver.GetPackageFilePath(library.Name, library.Version);
            var hashPath = packagePathResolver.GetHashPath(library.Name, library.Version);

            // Acquire the lock on a nukpg before we extract it to prevent the race condition when multiple
            // processes are extracting to the same destination simultaneously
            await ConcurrencyUtilities.ExecuteWithFileLocked(targetNupkg, async createdNewLock =>
            {
                // If this is the first process trying to install the target nupkg, go ahead
                // After this process successfully installs the package, all other processes
                // waiting on this lock don't need to install it again
                if (createdNewLock)
                {
                    Directory.CreateDirectory(targetPath);
                    using (var nupkgStream = new FileStream(targetNupkg, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete))
                    {
                        await stream.CopyToAsync(nupkgStream);
                        nupkgStream.Seek(0, SeekOrigin.Begin);

                        ExtractPackage(targetPath, nupkgStream);
                    }

                    // Fixup the casing of the nuspec on disk to match what we expect
                    var nuspecFile = Directory.EnumerateFiles(targetPath, "*" + NuGet.Constants.ManifestExtension).Single();

                    if (!string.Equals(nuspecFile, targetNuspec, StringComparison.Ordinal))
                    {
                        Manifest manifest = null;
                        using (var nuspecStream = File.OpenRead(nuspecFile))
                        {
                            manifest = Manifest.ReadFrom(nuspecStream, validateSchema: false);
                            manifest.Metadata.Id = library.Name;
                        }

                        // Delete the previous nuspec file
                        File.Delete(nuspecFile);

                        // Write the new manifest
                        using (var targetNuspecStream = File.OpenWrite(targetNuspec))
                        {
                            manifest.Save(targetNuspecStream);
                        }
                    }

                    stream.Seek(0, SeekOrigin.Begin);
                    var nupkgSHA = Convert.ToBase64String(sha512.ComputeHash(stream));
                    File.WriteAllText(hashPath, nupkgSHA);
                }

                return 0;
            });
        }
Esempio n. 5
0
    // Encrypt a password using SHA512
    public static byte[] EncryptPassword(string password)
    {
        // Make precalculated, generic rainbow tables ineffective by using a salt
        password = StaticSaltPassword(password);

        // Encrypt the password
        System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create();
        return(sha512.ComputeHash(System.Text.Encoding.Unicode.GetBytes(password)));
    }
 /// <summary>
 /// CheckSum512 method implementation
 /// </summary>
 public static byte[] CheckSum512(byte[] value)
 {
     byte[] hash = null;
     using (System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512Cng.Create())
     {
         hash = sha512.ComputeHash(value);
     }
     return(hash);
 }
 /// <summary>
 /// CheckSum512 method implementation
 /// </summary>
 public static byte[] CheckSum512(string value)
 {
     byte[] hash = null;
     using (System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512Managed.Create())
     {
         hash = sha512.ComputeHash(Encoding.UTF8.GetBytes(value));
     }
     return(hash);
 }
Esempio n. 8
0
File: Hash.cs Progetto: 4vz/Aveezo
        public static byte[] SHA512(byte[] input)
        {
            if (sha512 == null)
            {
                sha512 = System.Security.Cryptography.SHA512.Create();
            }

            return(sha512.ComputeHash(input));
        }
Esempio n. 9
0
        public override string StringHashAlgorithm(string value)
        {
            System.Security.Cryptography.SHA512 sha = System.Security.Cryptography.SHA512.Create();
            byte[]        bytes = sha.ComputeHash(System.Text.ASCIIEncoding.UTF8.GetBytes(value));
            StringBuilder sb    = new StringBuilder();

            foreach (var b in bytes)
            {
                sb.Append(b.ToString("x2"));
            }
            return(sb.ToString());
        }
Esempio n. 10
0
        public static string GetSHA512Hashed(string input)
        {
            System.Security.Cryptography.SHA512 sha1 = System.Security.Cryptography.SHA512.Create();

            byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(input.ToString()));

            StringBuilder output = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                output.Append(hash[i].ToString("X2"));
            }
            return(output.ToString());
        }
Esempio n. 11
0
        // sha512 below
        public static string GetSHA512Hash(string str)
        {
            System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create();
            byte[] bytes   = Encoding.Default.GetBytes(str);
            byte[] encoded = sha512.ComputeHash(bytes);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < encoded.Length; i++)
            {
                sb.Append(encoded[i].ToString("x2"));
            }

            return(sb.ToString());
        }
Esempio n. 12
0
        private void CompareBlocks(ShaAlg Algorithm)
        {
            if (Algorithm == ShaAlg.SHA256)
            {
                byte[] buffer = new byte[639];
                byte[] hash1  = new byte[32];
                byte[] hash2  = new byte[32];

                using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
                    rng.GetBytes(buffer);

                // SHA256 //
                // test digest
                using (VTDev.Projects.CEX.Crypto.Digests.SHA256Digest sha1 = new VTDev.Projects.CEX.Crypto.Digests.SHA256Digest())
                    hash1 = sha1.ComputeHash(buffer);

                using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256Managed.Create())
                    hash2 = sha.ComputeHash(buffer);

                if (!Compare.AreEqual(hash1, hash2))
                {
                    throw new Exception("SHA512 hash is not equal!");
                }
            }
            else
            {
                // SHA512 //
                byte[] hash1  = new byte[64];
                byte[] hash2  = new byte[64];
                byte[] buffer = new byte[377];

                using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
                    rng.GetBytes(buffer);

                // test digest
                using (VTDev.Projects.CEX.Crypto.Digests.SHA512Digest sha2 = new VTDev.Projects.CEX.Crypto.Digests.SHA512Digest())
                    hash1 = sha2.ComputeHash(buffer);

                using (System.Security.Cryptography.SHA512 sha = System.Security.Cryptography.SHA512Managed.Create())
                    hash2 = sha.ComputeHash(buffer);

                if (!Compare.AreEqual(hash1, hash2))
                {
                    throw new Exception("SHA256 hash is not equal!");
                }
            }
        }
Esempio n. 13
0
        public static string GetSha512(string value)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            value = value.Trim();
            if (value == string.Empty)
            {
                return(string.Empty);
            }

            try
            {
                System.Security.Cryptography.SHA512 oHash =
                    System.Security.Cryptography.SHA512.Create();

                byte[] bytInputs =
                    System.Text.Encoding.ASCII.GetBytes(value);

                byte[] bytHashes = oHash.ComputeHash(bytInputs);

                // Convert the byte array to hexadecimal string
                System.Text.StringBuilder oStringBuilder =
                    new System.Text.StringBuilder();

                for (int intIndex = 0; intIndex < bytHashes.Length; intIndex++)
                {
                    oStringBuilder.Append(bytHashes[intIndex].ToString("X2"));

                    // To force the hex string to lower-case letters instead of
                    // upper-case, use he following line instead:
                    // sb.Append(hashBytes[i].ToString("x2"));
                }

                return(oStringBuilder.ToString());

                //return (System.Web.Security.FormsAuthentication
                //	.HashPasswordForStoringInConfigFile(value, "SHA1"));
            }
            catch
            {
                return(string.Empty);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Return SHA-512 (SHA-2) for a string.
        /// </summary>
        /// <param name="text">Source text to calculate hash from</param>
        /// <param name="encoding">Text encoding</param>
        /// <returns>SHA1 hash in hex format</returns>
        public static string SHA512(string text, Encoding encoding)
        {
            if (text == null)
            {
                return(null);
            }
#if !NETCF
            using (System.Security.Cryptography.SHA512 cipher = System.Security.Cryptography.SHA512.Create())
            {
                byte[] array = cipher.ComputeHash(encoding.GetBytes(text));
                return(Energy.Base.Hex.ArrayToHex(array).ToLower());
            }
#endif
#if NETCF
            return(null);
#endif
        }
        /// <summary>
        /// 获取md5值
        /// </summary>
        /// <param name="md5Hash"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        private static string GetSHA512Hash(SHA512 hash, string input)
        {

            // Convert the input string to a byte array and compute the hash.
            byte[] data = hash.ComputeHash(Encoding.UTF8.GetBytes(input));

            // Create a new Stringbuilder to collect the bytes
            // and create a string.
            StringBuilder sBuilder = new StringBuilder();

            // Loop through each byte of the hashed data 
            // and format each one as a hexadecimal string.
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }

            // Return the hexadecimal string.
            return sBuilder.ToString();
        }
Esempio n. 16
0
        /// <summary>
        /// Get SHA1 hash from buffer of bytes
        /// </summary>
        /// <param name="input_buffer">Input buffer</param>
        /// <returns>16-byte array of hash</returns>
        public static byte[] GetSHAHash(byte[] input_buffer, SHAType shaType)
        {
            switch (shaType)
            {
            case SHAType.SHA1:
                SHA1 sha1 = new SHA1CryptoServiceProvider();
                return(sha1.ComputeHash(input_buffer));

            case SHAType.SHA256:
                System.Security.Cryptography.SHA256 sha256 = System.Security.Cryptography.SHA256.Create();
                return(sha256.ComputeHash(input_buffer));

            case SHAType.SHA384:
                System.Security.Cryptography.SHA384 sha384 = System.Security.Cryptography.SHA384.Create();
                return(sha384.ComputeHash(input_buffer));

            case SHAType.SHA512:
                System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create();
                return(sha512.ComputeHash(input_buffer));
            }
            return(null);
        }
Esempio n. 17
0
 public override byte[] ByteHashAlgorithm(string value)
 {
     System.Security.Cryptography.SHA512 sha = System.Security.Cryptography.SHA512.Create();
     byte[] bytes = sha.ComputeHash(System.Text.ASCIIEncoding.UTF8.GetBytes(value));
     return(bytes);
 }
Esempio n. 18
0
        internal static async Task InstallFromStream(Stream stream,
            Library library,
            string packagesDirectory,
            SHA512 sha512,
            bool performingParallelInstalls = false)
        {
            var packagePathResolver = new DefaultPackagePathResolver(packagesDirectory);

            var targetPath = packagePathResolver.GetInstallPath(library.Name, library.Version);
            var targetNuspec = packagePathResolver.GetManifestFilePath(library.Name, library.Version);
            var targetNupkg = packagePathResolver.GetPackageFilePath(library.Name, library.Version);
            var hashPath = packagePathResolver.GetHashPath(library.Name, library.Version);

            // Acquire the lock on a nukpg before we extract it to prevent the race condition when multiple
            // processes are extracting to the same destination simultaneously
            await ConcurrencyUtilities.ExecuteWithFileLocked(targetNupkg, async createdNewLock =>
            {
                // If this is the first process trying to install the target nupkg, go ahead
                // After this process successfully installs the package, all other processes
                // waiting on this lock don't need to install it again.
                if (createdNewLock && !File.Exists(targetNupkg))
                {
                    var extractPath = targetPath;
                    if (performingParallelInstalls)
                    {
                        // Extracting to the {id}/{version} has an issue with concurrent installs - when a package has been partially
                        // extracted, the Restore Operation can inadvertly conclude the package is available locally and proceed to read
                        // partially written package contents. To avoid this we'll extract the package to a sibling directory and Move it 
                        // to the target path.
                        extractPath = Path.Combine(Path.GetDirectoryName(targetPath), Path.GetRandomFileName());
                        targetNupkg = Path.Combine(extractPath, Path.GetFileName(targetNupkg));
                    }

                    var extractDirectory = Directory.CreateDirectory(extractPath);
                    using (var nupkgStream = new FileStream(
                        targetNupkg,
                        FileMode.Create,
                        FileAccess.ReadWrite,
                        FileShare.ReadWrite | FileShare.Delete,
                        bufferSize: 4096,
                        useAsync: true))
                    {
                        await stream.CopyToAsync(nupkgStream);
                        nupkgStream.Seek(0, SeekOrigin.Begin);

                        ExtractPackage(extractPath, nupkgStream);
                    }

                    // Fixup the casing of the nuspec on disk to match what we expect
                    var nuspecFile = Directory.EnumerateFiles(targetPath, "*" + NuGet.Constants.ManifestExtension).Single();

                    if (!string.Equals(nuspecFile, targetNuspec, StringComparison.Ordinal))
                    {
                        Manifest manifest = null;
                        using (var nuspecStream = File.OpenRead(nuspecFile))
                        {
                            manifest = Manifest.ReadFrom(nuspecStream, validateSchema: false);
                            manifest.Metadata.Id = library.Name;
                        }

                        // Delete the previous nuspec file
                        File.Delete(nuspecFile);

                        // Write the new manifest
                        using (var targetNuspecStream = File.OpenWrite(targetNuspec))
                        {
                            manifest.Save(targetNuspecStream);
                        }
                    }

                    stream.Seek(0, SeekOrigin.Begin);
                    var nupkgSHA = Convert.ToBase64String(sha512.ComputeHash(stream));
                    File.WriteAllText(hashPath, nupkgSHA);

                    if (performingParallelInstalls)
                    {
                        extractDirectory.MoveTo(targetPath);
                    }
                }

                return 0;
            });
        }
Esempio n. 19
0
        public static LockFileLibrary CreateLockFileLibraryForProject(
            Runtime.Project project,
            IPackage package,
            SHA512 sha512,
            IEnumerable<FrameworkName> frameworks,
            IPackagePathResolver resolver,
            string correctedPackageName = null)
        {
            var lockFileLib = new LockFileLibrary();

            // package.Id is read from nuspec and it might be in wrong casing.
            // correctedPackageName should be the package name used by dependency graph and
            // it has the correct casing that runtime needs during dependency resolution.
            lockFileLib.Name = correctedPackageName ?? package.Id;
            lockFileLib.Version = package.Version;

            using (var nupkgStream = package.GetStream())
            {
                lockFileLib.Sha = Convert.ToBase64String(sha512.ComputeHash(nupkgStream));
            }
            lockFileLib.Files = package.GetFiles().Select(p => p.Path).ToList();

            foreach (var framework in frameworks)
            {
                var group = new LockFileFrameworkGroup();
                group.TargetFramework = framework;

                IEnumerable<PackageDependencySet> dependencySet;
                if (VersionUtility.TryGetCompatibleItems(framework, package.DependencySets, out dependencySet))
                {
                    var set = dependencySet.FirstOrDefault()?.Dependencies?.ToList();

                    if (set != null)
                    {
                        group.Dependencies = set;
                    }
                }

                // TODO: Remove this when we do #596
                // ASP.NET Core isn't compatible with generic PCL profiles
                if (!string.Equals(framework.Identifier, VersionUtility.AspNetCoreFrameworkIdentifier, StringComparison.OrdinalIgnoreCase) &&
                    !string.Equals(framework.Identifier, VersionUtility.DnxCoreFrameworkIdentifier, StringComparison.OrdinalIgnoreCase))
                {
                    IEnumerable<FrameworkAssemblyReference> frameworkAssemblies;
                    if (VersionUtility.TryGetCompatibleItems(framework, package.FrameworkAssemblies, out frameworkAssemblies))
                    {
                        foreach (var assemblyReference in frameworkAssemblies)
                        {
                            if (!assemblyReference.SupportedFrameworks.Any() &&
                                !VersionUtility.IsDesktop(framework))
                            {
                                // REVIEW: This isn't 100% correct since none *can* mean
                                // any in theory, but in practice it means .NET full reference assembly
                                // If there's no supported target frameworks and we're not targeting
                                // the desktop framework then skip it.

                                // To do this properly we'll need all reference assemblies supported
                                // by each supported target framework which isn't always available.
                                continue;
                            }

                            group.FrameworkAssemblies.Add(assemblyReference);
                        }
                    }
                }

                group.RuntimeAssemblies = GetPackageAssemblies(package, framework);

                string contractPath = Path.Combine("lib", "contract", package.Id + ".dll");
                var hasContract = lockFileLib.Files.Any(path => path == contractPath);
                var hasLib = group.RuntimeAssemblies.Any();

                if (hasContract && hasLib && !VersionUtility.IsDesktop(framework))
                {
                    group.CompileTimeAssemblies.Add(contractPath);
                }
                else if (hasLib)
                {
                    group.CompileTimeAssemblies.AddRange(group.RuntimeAssemblies);
                }

                lockFileLib.FrameworkGroups.Add(group);
            }

            var installPath = resolver.GetInstallPath(package.Id, package.Version);
            foreach (var assembly in lockFileLib.FrameworkGroups.SelectMany(f => f.RuntimeAssemblies))
            {
                var assemblyPath = Path.Combine(installPath, assembly);
                if (IsAssemblyServiceable(assemblyPath))
                {
                    lockFileLib.IsServiceable = true;
                    break;
                }
            }

            return lockFileLib;
        }
 /// <summary>
 /// Gets the SHA512 of the password.
 /// </summary>
 /// <param name="password">the password to hash.</param>
 /// <param name="hashProvider">The hash provider.</param>
 /// <returns>The computed hash.</returns>
 private static byte[] GetHash(
     SecureString password,
     SHA512 hashProvider)
 {
     byte[] encodedText = password.ToEncodedClearText();
     try
     {
         return hashProvider.ComputeHash(encodedText);
     }
     finally
     {
         encodedText.Zero();
     }
 }
Esempio n. 21
0
    IEnumerator Login(string formScreenName, string formPassword)
    {
        string formText = "";
        string URL      = UserBlobManager.GetComponent <UserBlobManager>().ServerURL + "uw.php";
        string hash     = UserBlobManager.GetComponent <UserBlobManager>().ServerHash;
        string date     = System.DateTime.Now.Year.ToString("D4");

        date += System.DateTime.Now.Month.ToString("D2");
        date += System.DateTime.Now.Day.ToString("D2");

        // encrypt the password
        byte[] bytes = System.Text.Encoding.ASCII.GetBytes(hash + formPassword);
        System.Security.Cryptography.SHA512 sha = System.Security.Cryptography.SHA512.Create();
        byte[] shaHash = sha.ComputeHash(bytes);
        string result  = ByteArrayToHexString(shaHash);

        WWWForm form = new WWWForm();

        form.AddField("action", "login");
        form.AddField("myform_hash", hash);
        form.AddField("myform_ScreenName", formScreenName);
        form.AddField("myform_Password", result);
        form.AddField("myform_Date", date);
        WWW w = new WWW(URL, form);

        yield return(w);

        if (w.error != null)
        {
            // connection error
            print(w.error);

            if (w.error.Contains("Could not resolve host"))
            {
                if (PopUpActive == false)
                {
                    PopUpOkDialog("Can NOT connect to server.\nPlease check your internet connection.", this.gameObject.GetComponent <UI_Login>(), "WrongScreenNamePassword");
                }
            }
        }
        else
        {
            formText = w.text;

            if (formText.Contains("HASH code is different from your app"))
            {
                print("Can't connect");
                w.Dispose();
                if (PopUpActive == false)
                {
                    PopUpOkDialog("Cant connect to server.", this.gameObject.GetComponent <UI_Login>(), "WrongScreenNamePassword");
                }
            }
            else
            {
                if (formText.Contains("ScreenName or password is wrong."))
                {
                    if (PopUpActive == false)
                    {
                        PopUpOkDialog("Screen name or password is wrong.", this.gameObject.GetComponent <UI_Login>(), "WrongScreenNamePassword");
                    }
                }

                if (formText.Contains("Data invalid - cant find name"))
                {
                    if (PopUpActive == false)
                    {
                        PopUpOkDialog("Screen name is wrong.", this.gameObject.GetComponent <UI_Login>(), "WrongScreenNamePassword");
                    }
                }

                if (formText.Contains("PASSWORD CORRECT"))
                {
                    print("Login OK");
                    string[] tempArray = formText.Split('#');

                    string name          = tempArray[1];
                    string firstName     = tempArray[2];
                    string lastName      = tempArray[3];
                    string email         = tempArray[4];
                    string streetAddress = tempArray[5];
                    string city          = tempArray[6];
                    string state         = tempArray[7];
                    string zip           = tempArray[8];
                    string gender        = tempArray[9];

                    if (UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.RememberLoginPassword == true)
                    {
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserLogin         = name;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserPassword      = formPassword;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserFirstName     = firstName;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserLastName      = lastName;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserEmail         = email;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserStreetAddress = streetAddress;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserCity          = city;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserState         = state;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserZip           = zip;
                        UserBlobManager.GetComponent <UserBlobManager>().UserSettingsData.UserGender        = gender;
                        UserBlobManager.GetComponent <UserBlobManager>().SaveSettings();
                    }
                    UserBlobManager.GetComponent <UserBlobManager>().UserDownloadTrainingDataString = "";
                    UserBlobManager.GetComponent <UserBlobManager>().UserDownloadWorkoutDataString  = "";
                    UserBlobManager.GetComponent <UserBlobManager>().UserDownloadExerciseDataString = "";
                    UIShare.GetComponent <UI_Share>().UpdateFriendList = true;
                    UIManager.GetComponent <UI_Manager>().SwitchStates("ShareState");
                }
            }
        }
        w.Dispose();
    }
Esempio n. 22
0
        private LockFileLibrary CreateLockFileLibrary(LocalPackageInfo package, SHA512 sha512, string correctedPackageName)
        {
            var lockFileLib = new LockFileLibrary();

            // package.Id is read from nuspec and it might be in wrong casing.
            // correctedPackageName should be the package name used by dependency graph and
            // it has the correct casing that runtime needs during dependency resolution.
            lockFileLib.Name = correctedPackageName ?? package.Id;
            lockFileLib.Version = package.Version;

            using (var nupkgStream = File.OpenRead(package.ZipPath))
            {
                lockFileLib.Sha512 = Convert.ToBase64String(sha512.ComputeHash(nupkgStream));
                nupkgStream.Seek(0, SeekOrigin.Begin);

                var packageReader = new PackageReader(nupkgStream);

                // Get package files, excluding directory entries
                lockFileLib.Files = packageReader.GetFiles().Where(x => !x.EndsWith("/")).ToList();
            }

            return lockFileLib;
        }
Esempio n. 23
0
	public void FIPS186_c (string testName, SHA512 hash, byte[] input, byte[] result) 
	{
		MemoryStream ms = new MemoryStream (input);
		byte[] output = hash.ComputeHash (ms); 
		Assert.AreEqual (result, output, testName + ".c.1");
		Assert.AreEqual (result, hash.Hash, testName + ".c.2");
		// required or next operation will still return old hash
		hash.Initialize ();
	}
Esempio n. 24
0
	public void FIPS186_b (string testName, SHA512 hash, byte[] input, byte[] result) 
	{
		byte[] output = hash.ComputeHash (input, 0, input.Length); 
		Assert.AreEqual (result, output, testName + ".b.1");
		Assert.AreEqual (result, hash.Hash, testName + ".b.2");
		// required or next operation will still return old hash
		hash.Initialize ();
	}
Esempio n. 25
0
	public void FIPS186_a (string testName, SHA512 hash, byte[] input, byte[] result) 
	{
		byte[] output = hash.ComputeHash (input); 
		AssertEquals (testName + ".a.1", result, output);
		AssertEquals (testName + ".a.2", result, hash.Hash);
		// required or next operation will still return old hash
		hash.Initialize ();
	}