Fix analyzers - don't use BitConverter
Some checks failed
Spell checking / Spell checking (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled

This commit is contained in:
Jaime Bernardo 2024-11-22 12:45:22 +00:00
parent 1f9fff353d
commit 354877e143

View File

@ -71,7 +71,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.MD5.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(fs));
}; };
#pragma warning restore CA5351 #pragma warning restore CA5351
fileExtension = ".md5"; fileExtension = ".md5";
@ -81,7 +81,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA1.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(fs));
}; };
#pragma warning restore CA5350 #pragma warning restore CA5350
fileExtension = ".sha1"; fileExtension = ".sha1";
@ -90,7 +90,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA256.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA256.Create().ComputeHash(fs));
}; };
fileExtension = ".sha256"; fileExtension = ".sha256";
break; break;
@ -98,7 +98,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA384.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA384.Create().ComputeHash(fs));
}; };
fileExtension = ".sha384"; fileExtension = ".sha384";
break; break;
@ -106,7 +106,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA512.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA512.Create().ComputeHash(fs));
}; };
fileExtension = ".sha512"; fileExtension = ".sha512";
break; break;
@ -114,7 +114,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA3_256.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA3_256.Create().ComputeHash(fs));
}; };
fileExtension = ".sha3-256"; fileExtension = ".sha3-256";
break; break;
@ -122,7 +122,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA3_384.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA3_384.Create().ComputeHash(fs));
}; };
fileExtension = ".sha3-384"; fileExtension = ".sha3-384";
break; break;
@ -130,7 +130,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
hashGeneratorFunction = (filename) => hashGeneratorFunction = (filename) =>
{ {
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
return BitConverter.ToString(System.Security.Cryptography.SHA3_512.Create().ComputeHash(fs)).Replace("-", string.Empty); return Convert.ToHexString(System.Security.Cryptography.SHA3_512.Create().ComputeHash(fs));
}; };
fileExtension = ".sha3-512"; fileExtension = ".sha3-512";
break; break;
@ -140,7 +140,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
Crc32 crc32 = new(); Crc32 crc32 = new();
crc32.Append(fs); crc32.Append(fs);
return BitConverter.ToString(crc32.GetCurrentHash()).Replace("-", string.Empty); return Convert.ToHexString(crc32.GetCurrentHash());
}; };
fileExtension = ".crc32"; fileExtension = ".crc32";
break; break;
@ -160,7 +160,7 @@ namespace PowerToys.FileActionsMenu.Plugins.Hashes
using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using FileStream fs = new(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
Crc64 crc64 = new(); Crc64 crc64 = new();
crc64.Append(fs); crc64.Append(fs);
return BitConverter.ToString(crc64.GetCurrentHash()).Replace("-", string.Empty); return Convert.ToHexString(crc64.GetCurrentHash());
}; };
fileExtension = ".crc64"; fileExtension = ".crc64";
break; break;