Skip to content

Commit

Permalink
- 通用类调整。
Browse files Browse the repository at this point in the history
  • Loading branch information
OdysseusYuan committed Feb 22, 2024
1 parent e1c650a commit b1529b7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
39 changes: 0 additions & 39 deletions LKY_OfficeTools/Common/Com_FileOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,45 +121,6 @@ internal static byte[] StreamToBytes(Stream stream)
stream.Seek(0, SeekOrigin.Begin);
return bytes;
}

internal static Stream BytesToStream(byte[] bytes)
{
Stream stream = new MemoryStream(bytes);
return stream;
}


/* - - - - - - - - - - - - - - - - - - - - - - - -
* Stream 和 文件之间的转换
* - - - - - - - - - - - - - - - - - - - - - - - */
internal static void StreamToFile(Stream stream, string fileName)
{
// 把 Stream 转换成 byte[]
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);

// 把 byte[] 写入文件
FileStream fs = new FileStream(fileName, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(bytes);
bw.Close();
fs.Close();
}

internal static Stream FileToStream(string fileName)
{
// 打开文件
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
// 读取文件的 byte[]
byte[] bytes = new byte[fileStream.Length];
fileStream.Read(bytes, 0, bytes.Length);
fileStream.Close();
// 把 byte[] 转换成 Stream
Stream stream = new MemoryStream(bytes);
return stream;
}
}

internal class Write
Expand Down
27 changes: 0 additions & 27 deletions LKY_OfficeTools/Common/Com_TextOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/

using System;
using System.Security.Cryptography;
using System.Text;
using static LKY_OfficeTools.Lib.Lib_AppLog;

namespace LKY_OfficeTools.Common
Expand Down Expand Up @@ -47,31 +45,6 @@ internal static string GetCenterText(string str, string strLeft, string strRight
}
}

internal static string GetRandomString(int length, bool useNum, bool useLow, bool useUpp, bool useSpe, string custom)
{
byte[] b = new byte[4];
new System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b);
Random r = new Random(BitConverter.ToInt32(b, 0));
string s = null, str = custom;
if (useNum == true) { str += "0123456789"; }
if (useLow == true) { str += "abcdefghijklmnopqrstuvwxyz"; }
if (useUpp == true) { str += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
if (useSpe == true) { str += "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; }
for (int i = 0; i < length; i++)
{
s += str.Substring(r.Next(0, str.Length - 1), 1);
}
return s;
}

internal static string Encrypt16(string strPwd)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(strPwd)), 4, 8);
t2 = t2.Replace("-", "");
return t2.ToLower();
}

internal static int GetStringTimes(string str, string scan_str)
{
try
Expand Down

0 comments on commit b1529b7

Please sign in to comment.